public Object invokeMethod(String name, Object args) {
        try {
            return super.invokeMethod(name, args);
        }
        // if the method was not found in the current scope (the script's methods)
        // let's try to see if there's a method closure with the same name in the binding
        catch (MissingMethodException mme) {
            try {
                if (name.equals(mme.getMethod())) {
                    Object boundClosure = getProperty(name);
                    if (boundClosure != null && boundClosure instanceof Closure) {
                        return ((Closure) boundClosure).call((Object[])args);
                    } else {
                        throw mme;
                    }
                } else {
                    throw mme;
                }
            } catch (MissingPropertyException mpe) {
                throw mme;
            }
        }
    }
public Object invokeMethod ( String name , Object args ) { try { return super . invokeMethod ( name , args ) ; } catch ( MissingMethodException mme ) { try { if ( name . equals ( mme . getMethod ( ) ) ) { Object boundClosure = getProperty ( name ) ; if ( boundClosure != null && boundClosure instanceof Closure ) { return ( ( Closure ) boundClosure ) . call ( ( Object [ ] ) args ) ; } else { throw mme ; } } else { throw mme ; } } catch ( MissingPropertyException mpe ) { throw mme ; } } }
Invoke a method (or closure in the binding) defined.

@param name method to call
@param args arguments to pass to the method
@return value