ToLambda() public method

Creates a lambda Proc that has the same target, context and self object as this block. Doesn't preserve the class of the Proc.
public ToLambda ( RubyLambdaMethodInfo method ) : Proc
method IronRuby.Runtime.Calls.RubyLambdaMethodInfo
return Proc
Ejemplo n.º 1
1
 internal RubyLambdaMethodInfo(Proc/*!*/ block, string/*!*/ definitionName, RubyMemberFlags flags, RubyModule/*!*/ declaringModule) 
     : base(flags, declaringModule) {
     Assert.NotNull(block, definitionName, declaringModule);
     _lambda = block.ToLambda(this);
     _definitionName = definitionName;
     _id = Interlocked.Increment(ref _Id);
 }
Ejemplo n.º 2
0
        public static Proc /*!*/ DefineMethod(RubyScope /*!*/ scope, RubyModule /*!*/ self,
                                              [DefaultProtocol] string /*!*/ methodName, [NotNull] Proc /*!*/ method)
        {
            // MRI: ignores ModuleFunction scope flag (doesn't create singleton method).
            // MRI 1.8: uses private visibility if module_function is applied (bug).
            // MFI 1.9: uses public visibility as we do, unless the name is special.
            var visibility = RubyUtils.GetSpecialMethodVisibility(scope.Visibility, methodName);

            self.AddMethod(methodName, Proc.ToLambdaMethodInfo(method.ToLambda(), methodName, visibility, self));
            return(method);
        }