Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/itamae-mitsurin/mitsurin/base.rb
Instance Method Summary collapse
Instance Method Details
#deep_merge(other_hash, &block) ⇒ Object
13 14 15 |
# File 'lib/itamae-mitsurin/mitsurin/base.rb', line 13 def deep_merge(other_hash, &block) dup.deep_merge!(other_hash, &block) end |
#deep_merge!(other_hash, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/itamae-mitsurin/mitsurin/base.rb', line 17 def deep_merge!(other_hash, &block) merge!(other_hash) do |key, this_val, other_val| if this_val.is_a?(Hash) && other_val.is_a?(Hash) this_val.deep_merge(other_val, &block) elsif block_given? yield(key, this_val, other_val) else other_val end end end |