private IRubyObject respond_to(final ThreadContext context, IRubyObject mname, final boolean includePrivate) { RubySymbol name = TypeConverter.checkID(mname); if (getMetaClass().respondsToMethod(name.idString(), !includePrivate)) return context.tru; /* if ( ( name = BlankSlateWrapper.handlesMethod(name) ) != null ) { RubyBoolean bound = checkMetaClassBoundMethod(context, name, includePrivate); if ( bound != null ) return bound; return context.fals; // un-bound (removed) method } */ //if ( ! (mname instanceof RubySymbol) ) mname = context.runtime.newSymbol(name); //IRubyObject respond = Helpers.invoke(context, this, "respond_to_missing?", mname, context.runtime.newBoolean(includePrivate)); //return context.runtime.newBoolean(respond.isTrue()); return context.nil; // NOTE: this is wrong - should be true but compatibility first, for now }
private IRubyObject respond_to(final ThreadContext context, IRubyObject mname, final boolean includePrivate) { RubySymbol name = TypeConverter.checkID(mname); if (getMetaClass().respondsToMethod(name.idString(), !includePrivate)) return context.tru; /* if ( ( name = BlankSlateWrapper.handlesMethod(name) ) != null ) { RubyBoolean bound = checkMetaClassBoundMethod(context, name, includePrivate); if ( bound != null ) return bound; return context.fals; // un-bound (removed) method } */ //if ( ! (mname instanceof RubySymbol) ) mname = context.runtime.newSymbol(name); //IRubyObject respond = Helpers.invoke(context, this, "respond_to_missing?", mname, context.runtime.newBoolean(includePrivate)); //return context.runtime.newBoolean(respond.isTrue()); return context.nil; // NOTE: this is wrong - should be true but compatibility first, for now }
/** obj_respond_to * * respond_to?( aSymbol, includePriv=false ) -> true or false * * Returns true if this object responds to the given method. Private * methods are included in the search only if the optional second * parameter evaluates to true. * * @return true if this responds to the given method * * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 * * Going back to splitting according to method arity. MRI is wrong * about most of these anyway, and since we have arity splitting * in both the compiler and the interpreter, the performance * benefit is important for this method. */ @Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only) public final RubyBoolean respond_to_p(IRubyObject mname) { return getRuntime().newBoolean(getMetaClass().respondsToMethod(mname.asJavaString(), true)); }
/** obj_respond_to * * respond_to?( aSymbol, includePriv=false ) -> true or false * * Returns true if this object responds to the given method. Private * methods are included in the search only if the optional second * parameter evaluates to true. * * @return true if this responds to the given method * * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 * * Going back to splitting according to method arity. MRI is wrong * about most of these anyway, and since we have arity splitting * in both the compiler and the interpreter, the performance * benefit is important for this method. */ @Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only) public final RubyBoolean respond_to_p(IRubyObject mname) { return getRuntime().newBoolean(getMetaClass().respondsToMethod(mname.asJavaString(), true)); }
final RubyBoolean respond_to_p(ThreadContext context, IRubyObject methodName, final boolean includePrivate) { final Ruby runtime = context.runtime; final String name = methodName.asJavaString(); if (getMetaClass().respondsToMethod(name, !includePrivate)) return runtime.getTrue(); // MRI (1.9) always passes down a symbol when calling respond_to_missing? if ( ! (methodName instanceof RubySymbol) ) methodName = runtime.newSymbol(name); IRubyObject respond = sites(context).respond_to_missing.call(context, this, this, methodName, runtime.newBoolean(includePrivate)); return runtime.newBoolean( respond.isTrue() ); }
final RubyBoolean respond_to_p(ThreadContext context, IRubyObject methodName, final boolean includePrivate) { final Ruby runtime = context.runtime; final String name = methodName.asJavaString(); if (getMetaClass().respondsToMethod(name, !includePrivate)) return runtime.getTrue(); // MRI (1.9) always passes down a symbol when calling respond_to_missing? if ( ! (methodName instanceof RubySymbol) ) methodName = runtime.newSymbol(name); IRubyObject respond = sites(context).respond_to_missing.call(context, this, this, methodName, runtime.newBoolean(includePrivate)); return runtime.newBoolean( respond.isTrue() ); }
return getMetaClass().respondsToMethod(name, false);
return getMetaClass().respondsToMethod(name, false);