From: "skwosh (Alex Goldsmith)" Date: 2013-03-02T23:10:28+09:00 Subject: [ruby-core:53106] [ruby-trunk - Bug #8005][Open] Methods made private/protected after definition are made uncallable by prepend Issue #8005 has been reported by skwosh (Alex Goldsmith). ---------------------------------------- Bug #8005: Methods made private/protected after definition are made uncallable by prepend https://bugs.ruby-lang.org/issues/8005 Author: skwosh (Alex Goldsmith) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0] Prepending a module seems to break method resolution for methods that have been made `private` or `protected` via the `def private *names` and `def protected *names` methods. ___ class A end A.send :prepend, Module.new {} # Works if this line is removed... class A def foo() end protected :foo # Also works if we use the argument-less form of "protected"... end A.new.respond_to? :foo, true # => true A.new.send :foo # => NoMethodError: undefined method `foo' for # ___ Note that it correctly reports that it can respond_to?... This breaks in Rails 4 when trying to prepend to an ActiveRecord::Base (due to dynamically defined model callbacks). -- http://bugs.ruby-lang.org/