Module: Representable::Inheritable::Hash::InstanceMethods
- Included in:
- Representable::Inheritable::Hash
- Defined in:
- lib/representable/inheritable.rb
Instance Method Summary collapse
Instance Method Details
#clone ⇒ Object
36 37 38 |
# File 'lib/representable/inheritable.rb', line 36 def clone self.class[ collect { |k,v| [k, clone_value(v)] } ] end |
#inherit!(parent) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/representable/inheritable.rb', line 22 def inherit!(parent) #merge!(parent.clone) for key in (parent.keys + keys).uniq next unless parent_value = parent[key] self[key].inherit!(parent_value) and next if self[key].is_a?(Inheritable) self[key] = parent_value.clone and next if parent_value.is_a?(Cloneable) self[key] = parent_value # merge! behaviour end self end |