IronRuby.Builtins.RubyClass.CreateAnonymousClass C# (CSharp) Method

CreateAnonymousClass() public static method

public static CreateAnonymousClass ( IronRuby.Runtime.RubyScope scope, BlockParam body, RubyClass self, [ superClass ) : object
scope IronRuby.Runtime.RubyScope
body IronRuby.Runtime.BlockParam
self RubyClass
superClass [
return object
        public static object CreateAnonymousClass(RubyScope/*!*/ scope, BlockParam body, RubyClass/*!*/ self, [Optional]RubyClass superClass) {
            RubyContext context = scope.RubyContext;
            RubyModule owner = scope.GetInnerMostModuleForConstantLookup();
            
            // MRI is inconsistent here, it triggers "inherited" event after the body of the method is evaluated.
            // In all other cases the order is event first, body next.
            RubyClass newClass = context.DefineClass(owner, null, superClass ?? context.ObjectClass, null);
            return (body != null) ? RubyUtils.EvaluateInModule(newClass, body, new[] { newClass }, newClass) : newClass;
        }