38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/httparty/module_inheritable_attributes.rb', line 38
def inherited(subclass)
super
@mattr_inheritable_attrs.each do |inheritable_attribute|
ivar = :"@#{inheritable_attribute}"
subclass.instance_variable_set(ivar, instance_variable_get(ivar).clone)
if instance_variable_get(ivar).respond_to?(:merge)
subclass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
def self.#{inheritable_attribute}
duplicate = ModuleInheritableAttributes.hash_deep_dup(#{ivar})
#{ivar} = superclass.#{inheritable_attribute}.merge(duplicate)
end
RUBY
end
end
end
|