Class: Furi::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/furi/utils.rb

Class Method Summary collapse

Class Method Details

.deep_merge(current_hash, other_hash) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/furi/utils.rb', line 14

def deep_merge(current_hash, other_hash)
  current_hash.merge(other_hash) do |key, this_val, other_val|
   if this_val.is_a?(Hash) && other_val.is_a?(Hash)
     deep_merge(this_val, other_val)
   else
     other_val
   end
 end
end

.stringify_keys(hash) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/furi/utils.rb', line 5

def stringify_keys(hash)
  result = {}
  hash.each_key do |key|
    value = hash[key]
    result[key.to_s] = value.is_a?(Hash) ? stringify_keys(value) : value
  end
  result
end