Module: Anyway::Utils

Defined in:
lib/anyway/utils/deep_merge.rb

Class Method Summary collapse

Class Method Details

.deep_merge!(source, other) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/anyway/utils/deep_merge.rb', line 7

def self.deep_merge!(source, other)
  other.each do |key, other_value|
    this_value = source[key]

    if this_value.is_a?(::Hash) && other_value.is_a?(::Hash)
      deep_merge!(this_value, other_value)
    else
      source[key] = other_value.deep_dup
    end
  end

  source
end