Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/gorgon/core_ext/hash/deep_merge.rb
Overview
Algorithm from ‘activesupport/core_ext/hash/deep_merge’
Instance Method Summary collapse
Instance Method Details
#deep_merge(other_hash) ⇒ Object
4 5 6 |
# File 'lib/gorgon/core_ext/hash/deep_merge.rb', line 4 def deep_merge(other_hash) dup.deep_merge!(other_hash) end |
#deep_merge!(other_hash) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gorgon/core_ext/hash/deep_merge.rb', line 8 def deep_merge!(other_hash) other_hash.each_pair do |current_key, other_value| this_value = self[current_key] self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash) this_value.deep_merge(other_value) else other_value end end self end |