[Ironruby-core] RubyModule CreateAnonymousModule - NotImplementedException

Peter Bacon Darwin bacondarwin at googlemail.com
Sun Sep 28 10:55:59 EDT 2008

And if you want the monkey patching to work then this should help...

In RubyModule.cs you need:

        // Ruby constructor:
        public static RubyModule/*!*/
CreateAnonymousModule([NotNull]BlockParam/*!*/ block, RubyClass/*!*/ self) {
            RubyModule module =
            object returnedValue =
RubySites.ModuleEval(block.Proc.LocalScope, module, block.Proc);
            if ( block.BlockJumped(returnedValue) ) {
                return null;
            return module;

And in RubySites.cs you need:

        private static readonly CallSite<Func<CallSite, CodeContext,
RubyModule, Proc, object>> ModuleEvalSharedSite = CallSite<Func<CallSite,
CodeContext, RubyModule, Proc, object>>.Create(

        public static object ModuleEval(CodeContext context, RubyModule
self, Proc block) {
            return ModuleEvalSharedSite.Target(ModuleEvalSharedSite,
context, self, block);

There are probably a number of corner cases that I have missed but this
should work for the majority of uses.


More information about the Ironruby-core mailing list