instance method _stash_object_in_method

Ruby on Rails 4.0.13

Since v3.0.20 Last seen in v4.2.9 Private

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9

Signature

_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

object req
method req
instance_reader opt = true
Source
# File activesupport/lib/active_support/core_ext/class/delegating_attributes.rb, line 27
    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 27 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Class

Type at least 2 characters to search.

↑↓ navigate · open · esc close