instance method
_stash_object_in_method
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v4.2.9 PrivateSignature
_stash_object_in_method(object, method, instance_reader = true)
Take the object being set and store it in a method. This gives us automatic inheritance behavior, without having to store the object in an instance variable and look up the superclass chain manually.
Parameters
-
objectreq -
methodreq -
instance_readeropt = true
Source
# File activesupport/lib/active_support/core_ext/class/delegating_attributes.rb, line 30
def _stash_object_in_method(object, method, instance_reader = true)
singleton_class.remove_possible_method(method)
singleton_class.send(:define_method, method) { object }
remove_possible_method(method)
define_method(method) { object } if instance_reader
end
Defined in activesupport/lib/active_support/core_ext/class/delegating_attributes.rb line 30
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Class