Bug #3562: regression in respond_to?
http://redmine.ruby-lang.org/issues/show/3562

Author: Aaron Patterson
Status: Open, Priority: Normal
ruby -v: ruby 1.9.3dev (2010-07-12 trunk 28620) [x86_64-darwin10.3.1]

respond_to? returns false for protected methods.  This breaks classes that want to inflect on themselves.  For example:

    class Foo
      protected
      def do_bar
        "bar"
      end
    
      def method_missing name
        super unless respond_to?(:"do_#{name}")
        send(:"do_#{name}")
      end
    end
    
    class Subclass < Foo
      protected
      def do_baz
        "baz"
      end
    end
    
    p Foo.new.bar
    p Subclass.new.baz

This code works in 1.8, 1.9.2, but not trunk.  This change to respond_to?() breaks existing ruby code[1].  Is that intended?  Could we compromise by including private and protected methods when an object inflects upon itself?

1. http://github.com/svenfuchs/i18n/blob/master/lib/i18n/backend/base.rb#L203


----------------------------------------
http://redmine.ruby-lang.org