Module: Apia::DeepMerge
- Defined in:
- lib/apia/deep_merge.rb
Class Method Summary collapse
Class Method Details
.merge(hash_a, hash_b, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/apia/deep_merge.rb', line 8 def merge(hash_a, hash_b, &block) hash_a.merge!(hash_b) do |key, this_val, other_val| if this_val.is_a?(Hash) && other_val.is_a?(Hash) merge(this_val, other_val, &block) elsif block_given? block.call(key, this_val, other_val) else other_val end end end |