org.jruby.runtime.callback
Class ReflectionCallback

java.lang.Object
  extended by org.jruby.runtime.callback.ReflectionCallback
All Implemented Interfaces:
Callback

public class ReflectionCallback
extends java.lang.Object
implements Callback

A wrapper for java.lang.reflect.Method objects which implement Ruby methods.


Constructor Summary
ReflectionCallback(java.lang.Class type, java.lang.String methodName, java.lang.Class[] argumentTypes, boolean isRestArgs, boolean isStaticMethod, Arity arity, boolean fast)
           
 
Method Summary
 IRubyObject execute(IRubyObject recv, IRubyObject[] oargs, Block block)
          Calls a wrapped Ruby method for the specified receiver with the specified arguments.
 Arity getArity()
          Returns the arity of the wrapped Ruby method.
protected  java.lang.Object[] packageRestArgumentsForReflection(java.lang.Object[] originalArgs)
          Returns an object array that collects all rest arguments in its own object array which is then put into the last slot of the first object array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionCallback

public ReflectionCallback(java.lang.Class type,
                          java.lang.String methodName,
                          java.lang.Class[] argumentTypes,
                          boolean isRestArgs,
                          boolean isStaticMethod,
                          Arity arity,
                          boolean fast)
Method Detail

packageRestArgumentsForReflection

protected final java.lang.Object[] packageRestArgumentsForReflection(java.lang.Object[] originalArgs)
Returns an object array that collects all rest arguments in its own object array which is then put into the last slot of the first object array. That is, assuming that this callback expects one required argument and any number of rest arguments, an input of [1, 2, 3] is transformed into [1, [2, 3]].


execute

public IRubyObject execute(IRubyObject recv,
                           IRubyObject[] oargs,
                           Block block)
Calls a wrapped Ruby method for the specified receiver with the specified arguments.

Specified by:
execute in interface Callback

getArity

public Arity getArity()
Returns the arity of the wrapped Ruby method.

Specified by:
getArity in interface Callback


Copyright © 2002-2009 JRuby Team. All Rights Reserved.