class Class
Public Instance Methods
convey_attributes_to_child(child, *attributes)
click to toggle source
Extracted from Rails code base
# File lib/omu_support/core_ext/class.rb, line 5 def convey_attributes_to_child(child, *attributes) attributes.each { |attribute| child.__send__ "#{attribute}=", duplicated_attribute(attribute) } end
inherited_by_conveying_attributes(*attributes, &block)
click to toggle source
Calls superclass method
# File lib/omu_support/core_ext/class.rb, line 9 def inherited_by_conveying_attributes(*attributes, &block) define_singleton_method :inherited do |child| convey_attributes_to_child(child, *attributes) super(child) block&.call(child) end end
Private Instance Methods
duplicated_attribute(attribute)
click to toggle source
# File lib/omu_support/core_ext/class.rb, line 19 def duplicated_attribute(attribute) dup = __send__(attribute).dup case attribute when Hash then dup.each { |k, v| dup[k] = v.dup } when Array then dup.each_with_index { |v, i| dup[i] = v.dup } else dup end end