This project is closed and read-only.
Actions
Backport #8005
closedMethods made private/protected after definition are made uncallable by prepend
Backport #8005:
Methods made private/protected after definition are made uncallable by prepend
Status:
Closed
Assignee:
Description
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 #<A:...>
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).
Actions