public static object Reinitialize(BlockParam block, RubyModule /*!*/ self) { // no class can be reinitialized: if (self.IsClass) { throw RubyExceptions.CreateTypeError("already initialized class"); } return((block != null) ? RubyUtils.EvaluateInModule(self, block, null) : null); }
/// <summary> /// Struct#new /// Creates Struct classes with the specified name and members /// </summary> private static object Create(BlockParam block, RubyClass /*!*/ self, string className, string /*!*/[] /*!*/ attributeNames) { var result = RubyStruct.DefineStruct(self, className, attributeNames); if (block != null) { return(RubyUtils.EvaluateInModule(result, block, result)); } return(result); }
// TODO: public due to partial trust // implements Class#new public static object CreateAnonymousClass(RubyScope /*!*/ scope, BlockParam body, RubyClass /*!*/ self, [Optional] RubyClass superClass) { RubyContext ec = scope.RubyContext; RubyModule owner = scope.GetInnerMostModule(); // 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 = ec.DefineClass(owner, null, superClass ?? ec.ObjectClass); return((body != null) ? RubyUtils.EvaluateInModule(newClass, body, newClass) : newClass); }
public static object Evaluate([NotNull] BlockParam /*!*/ block, RubyModule /*!*/ self) { return(RubyUtils.EvaluateInModule(self, block)); }
public static object Execute([NotNull] BlockParam /*!*/ block, RubyModule /*!*/ self, params object[] /*!*/ args) { return(RubyUtils.EvaluateInModule(self, block, args)); }