Class: Class

Inherits:
Object show all
Defined in:
lib/omu_support/core_ext/class.rb

Instance Method Summary collapse

Instance Method Details

#convey_attributes_to_child(child, *attributes) ⇒ Object

Extracted from Rails code base



5
6
7
# 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) ⇒ Object



9
10
11
12
13
14
15
# 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