core/src/main/java/org/jruby/RubyBasicObject.java
@Override
    public final boolean respondsTo(String name) {
        final Ruby runtime = metaClass.runtime;
        final CacheEntry entry = metaClass.searchWithCache("respond_to?");
        final DynamicMethod respondTo = entry.method;

        // fastest path; builtin respond_to? and respond_to_missing? so we just check isMethodBound
        if ( respondTo.equals(runtime.getRespondToMethod()) &&
                metaClass.searchMethod("respond_to_missing?").equals(runtime.getRespondToMissingMethod()) ) {
            return metaClass.respondsToMethod(name, false);
        }

        final ThreadContext context = runtime.getCurrentContext();
        final RubySymbol mname = runtime.newSymbol(name);

        // respond_to? or respond_to_missing? is not defined, so we must dispatch to trigger method_missing
        if ( respondTo.isUndefined() ) {
            return sites(context).respond_to.call(context, this, this, mname).isTrue();
        } else {
            return respondTo.callRespondTo(context, this, "respond_to?", entry.sourceModule, mname);
        }
    }
/**
     * Does this object respond to the specified message? Uses a
     * shortcut if it can be proved that respond_to? and respond_to_missing?
     * haven't been overridden.
     */
Does this object respond to the specified message. Uses a
shortcut if it can be proved that respond_to.
Does this object respond to the specified message . Uses a shortcut if it can be proved that respond_to .
@Override
    public final boolean respondsTo(String name) {
        final Ruby runtime = metaClass.runtime;
        final CacheEntry entry = metaClass.searchWithCache("respond_to?");
        final DynamicMethod respondTo = entry.method;
        if ( respondTo.equals(runtime.getRespondToMethod()) &&
                metaClass.searchMethod("respond_to_missing?").equals(runtime.getRespondToMissingMethod()) ) {
            return metaClass.respondsToMethod(name, false);
        }
        final ThreadContext context = runtime.getCurrentContext();
        final RubySymbol mname = runtime.newSymbol(name);
        if ( respondTo.isUndefined() ) {
            return sites(context).respond_to.call(context, this, this, mname).isTrue();
        } else {
            return respondTo.callRespondTo(context, this, "respond_to?", entry.sourceModule, mname);
        }
    }
@ Override public final boolean respondsTo ( String name ) { final Ruby runtime = metaClass . runtime ; final CacheEntry entry = metaClass . searchWithCache ( "respond_to?" ) ; final DynamicMethod respondTo = entry . method ; if ( respondTo . equals ( runtime . getRespondToMethod ( ) ) && metaClass . searchMethod ( "respond_to_missing?" ) . equals ( runtime . getRespondToMissingMethod ( ) ) ) { return metaClass . respondsToMethod ( name , false ) ; } final ThreadContext context = runtime . getCurrentContext ( ) ; final RubySymbol mname = runtime . newSymbol ( name ) ; if ( respondTo . isUndefined ( ) ) { return sites ( context ) . respond_to . call ( context , this , this , mname ) . isTrue ( ) ; } else { return respondTo . callRespondTo ( context , this , "respond_to?" , entry . sourceModule , mname ) ; } }
Does this object respond to the specified message?
Does this object respond to the specified message?
// fastest path; builtin respond_to? and respond_to_missing? so we just check isMethodBound // respond_to? or respond_to_missing? is not defined, so we must dispatch to trigger method_missing