2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/soar_xt/soar_extend_hash.rb', line 2
def self.deep_merge(first, second)
if first.is_a?(Hash) and (second.is_a?(Hash))
result = first.merge(second)
end
first.each do |first_key, first_value|
second.each do |second_key, second_value|
if (first_key == second_key)
if first_value.is_a?(Hash) and (second_value.is_a?(Hash))
result[first_key] = Hash::deep_merge(first_value, second_value)
elsif first_value.is_a?(Array) and (second_value.is_a?(Array))
result[first_key] = first_value + second_value
else
puts "tbd"
end
end
end
end
result
end
|