Module: Raven::Utils::DeepMergeHash
- Defined in:
- lib/raven/utils/deep_merge.rb
Overview
ported from ActiveSupport
Class Method Summary collapse
Class Method Details
.deep_merge(hash, other_hash, &block) ⇒ Object
5 6 7 |
# File 'lib/raven/utils/deep_merge.rb', line 5 def self.deep_merge(hash, other_hash, &block) deep_merge!(hash, other_hash, &block) end |
.deep_merge!(hash, other_hash, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/raven/utils/deep_merge.rb', line 9 def self.deep_merge!(hash, other_hash, &block) other_hash.each_pair do |current_key, other_value| this_value = hash[current_key] hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash) this_value.deep_merge(other_value, &block) else if block_given? && key?(current_key) block.call(current_key, this_value, other_value) else other_value end end end hash end |