Module: HashDeepMergeExt
- Defined in:
- lib/elzar/core_ext/hash.rb
Instance Method Summary collapse
-
#deep_merge(other_hash) ⇒ Object
Implementation pulled from ActiveSupport.
- #deep_merge!(other_hash) ⇒ Object
Instance Method Details
#deep_merge(other_hash) ⇒ Object
Implementation pulled from ActiveSupport
4 5 6 |
# File 'lib/elzar/core_ext/hash.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 |
# File 'lib/elzar/core_ext/hash.rb', line 8 def deep_merge!(other_hash) other_hash.each_pair do |k,v| tv = self[k] self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v end self end |