Module: HashHelpers

Defined in:
lib/nswtopo/helpers/hash.rb

Instance Method Summary collapse

Instance Method Details

#deep_merge(other) ⇒ Object



2
3
4
5
6
# File 'lib/nswtopo/helpers/hash.rb', line 2

def deep_merge(other)
  merge(other) do |key, old_value, new_value|
    Hash === old_value ? Hash === new_value ? old_value.deep_merge(new_value) : new_value : new_value
  end
end

#deep_merge!(other) ⇒ Object



8
9
10
11
12
# File 'lib/nswtopo/helpers/hash.rb', line 8

def deep_merge!(other)
  merge!(other) do |key, old_value, new_value|
    Hash === old_value ? Hash === new_value ? old_value.deep_merge!(new_value) : new_value : new_value
  end
end