Module: WithDeepMerge

Included in:
Govspeak::HtmlSanitizer
Defined in:
lib/with_deep_merge.rb

Instance Method Summary collapse

Instance Method Details

#deep_merge(base_object, other_object) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/with_deep_merge.rb', line 2

def deep_merge(base_object, other_object)
  if base_object.is_a?(Hash) && other_object.is_a?(Hash)
    base_object.merge(other_object) { |_, base_value, other_value|
      deep_merge(base_value, other_value)
    }
  else
    other_object
  end
end