Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/wcc.rb
Instance Method Summary collapse
-
#recursive_merge(other) ⇒ Hash
Recursively merges the other hash into self while overwriting duplicate keys in self.
Instance Method Details
#recursive_merge(other) ⇒ Hash
Recursively merges the other hash into self while overwriting duplicate keys in self.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wcc.rb', line 55 def recursive_merge(other) copy = self.dup other.keys.each do |k| if other[k].is_a?(Hash) and self[k].is_a?(Hash) copy[k] = copy[k].recursive_merge(other[k]) else # ignore nils from other copy[k] = other[k] unless other[k].nil? end end copy end |