core/src/main/java/org/jruby/RubyProc.java
@JRubyMethod(name = "new", rest = true, meta = true)
    public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        // No passed in block, lets check next outer frame for one ('Proc.new')
        if (!block.isGiven()) block = context.getCurrentFrame().getBlock();

        // This metaclass == recv check seems gross, but MRI seems to do the same:
        // if (!proc && ruby_block->block_obj && CLASS_OF(ruby_block->block_obj) == klass) {
        if (block.isGiven() && block.getProcObject() != null && block.getProcObject().metaClass == recv) {
            return block.getProcObject();
        }

        RubyProc obj = new RubyProc(context.runtime, (RubyClass)recv, Block.Type.PROC);
        obj.setup(block);

        obj.callMethod(context, "initialize", args, block);
        return obj;
    }
/**
     * Create a new instance of a Proc object.  We override this method (from RubyClass)
     * since we need to deal with special case of Proc.new with no arguments or block arg.  In
     * this case, we need to check previous frame for a block to consume.
     */
Create a new instance of a Proc object.  We override this method (from RubyClass)
since we need to deal with special case of Proc.new with no arguments or block arg.  In
this case, we need to check previous frame for a block to consume.
Create a new instance of a Proc object . We override this method ( from RubyClass ) since we need to deal with special case of Proc . new with no arguments or block arg . In this case we need to check previous frame for a block to consume .
@JRubyMethod(name = "new", rest = true, meta = true)
    public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        if (!block.isGiven()) block = context.getCurrentFrame().getBlock();
        if (block.isGiven() && block.getProcObject() != null && block.getProcObject().metaClass == recv) {
            return block.getProcObject();
        }
        RubyProc obj = new RubyProc(context.runtime, (RubyClass)recv, Block.Type.PROC);
        obj.setup(block);
        obj.callMethod(context, "initialize", args, block);
        return obj;
    }
@ JRubyMethod ( name = "new" , rest = true , meta = true ) public static IRubyObject newInstance ( ThreadContext context , IRubyObject recv , IRubyObject [ ] args , Block block ) { if ( ! block . isGiven ( ) ) block = context . getCurrentFrame ( ) . getBlock ( ) ; if ( block . isGiven ( ) && block . getProcObject ( ) != null && block . getProcObject ( ) . metaClass == recv ) { return block . getProcObject ( ) ; } RubyProc obj = new RubyProc ( context . runtime , ( RubyClass ) recv , Block . Type . PROC ) ; obj . setup ( block ) ; obj . callMethod ( context , "initialize" , args , block ) ; return obj ; }
Create a new instance of a Proc object.
Create a new instance of a Proc object .
// No passed in block, lets check next outer frame for one ('Proc.new') // This metaclass == recv check seems gross, but MRI seems to do the same: // if (!proc && ruby_block->block_obj && CLASS_OF(ruby_block->block_obj) == klass) {