Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/sxn/templates/template_variables.rb,
lib/sxn/templates/template_engine.rb

Overview

Add deep_merge helper method to Hash class if not already present

Instance Method Summary collapse

Instance Method Details

#deep_merge(other_hash) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/sxn/templates/template_engine.rb', line 12

def deep_merge(other_hash)
  merge(other_hash) do |_key, oldval, newval|
    if oldval.is_a?(Hash) && newval.is_a?(Hash)
      oldval.deep_merge(newval)
    else
      newval
    end
  end
end