class Hash
Public Instance Methods
deep_merge(other)
click to toggle source
Merge not only the hashes, but all nested hashes as well. Written by Stefan Rusterholz (apeiros) from www.ruby-forum.com/topic/142809
# File lib/fidgit/standard_ext/hash.rb, line 14 def deep_merge(other) merger = lambda do |key, a, b| (a.is_a?(Hash) && b.is_a?(Hash)) ? a.merge(b, &merger) : b end merge(other, &merger) end
deep_merge!(other)
click to toggle source
Merge not only the hashes, but all nested hashes as well. Written by Stefan Rusterholz (apeiros) from www.ruby-forum.com/topic/142809
# File lib/fidgit/standard_ext/hash.rb, line 4 def deep_merge!(other) merger = lambda do |key, a, b| (a.is_a?(Hash) && b.is_a?(Hash)) ? a.merge!(b, &merger) : b end merge!(other, &merger) end