Class: Hash
Direct Known Subclasses
Instance Method Summary collapse
- #deep_merge!(second) ⇒ Object
- #keys_flat(keys_result = []) ⇒ Object
- #merge_nested_hash!(nested_hash) ⇒ Object
- #nested_hash(array) ⇒ Object
Instance Method Details
#deep_merge!(second) ⇒ Object
25 26 27 28 |
# File 'lib/lore/bits.rb', line 25 def deep_merge!(second) merger = proc { |key,v1,v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } self.merge!(second, &merger) end |
#keys_flat(keys_result = []) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/lore/bits.rb', line 43 def keys_flat(keys_result=[]) keys.each { |k| keys_result << k child = self[k] child.keys_flat(keys_result) if (child && child.kind_of?(Hash)) } return keys_result end |
#merge_nested_hash!(nested_hash) ⇒ Object
39 40 41 |
# File 'lib/lore/bits.rb', line 39 def merge_nested_hash!(nested_hash) deep_merge!(nested_hash) end |