Module: Wingtips::HashUtils
Instance Method Summary collapse
Instance Method Details
#deep_merge(hash1, hash2) ⇒ Object
5 6 7 |
# File 'lib/wingtips/hash_utils.rb', line 5 def deep_merge(hash1, hash2) deep_merge!(hash1.dup, hash2) end |
#deep_merge!(hash1, hash2) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/wingtips/hash_utils.rb', line 9 def deep_merge!(hash1, hash2) hash1.merge! hash2 do |_key, value1, value2| if value1.respond_to?(:merge!) && value2.respond_to?(:merge!) HashUtils.deep_merge! value1, value2 else value2 end end end |