123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::ClassAttribute

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: activesupport/lib/active_support/class_attribute.rb

Class Method Summary

Class Method Details

.redefine(owner, name, namespaced_name, value)

[ GitHub ]

  
# File 'activesupport/lib/active_support/class_attribute.rb', line 6

def redefine(owner, name, namespaced_name, value)
  if owner.singleton_class?
    if owner.attached_object.is_a?(Module)
      redefine_method(owner, namespaced_name, private: true) { value }
    else
      redefine_method(owner, name) { value }
    end
  end

  redefine_method(owner.singleton_class, namespaced_name, private: true) { value }

  redefine_method(owner.singleton_class, "#{namespaced_name}=", private: true) do |new_value|
    if owner.equal?(self)
      value = new_value
    else
      ::ActiveSupport::ClassAttribute.redefine(self, name, namespaced_name, new_value)
    end
  end
end

.redefine_method(owner, name, private: false, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/class_attribute.rb', line 26

def redefine_method(owner, name, private: false, &block)
  owner.silence_redefinition_of_method(name)
  owner.define_method(name, &block)
  owner.send(:private, name) if private
end