Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#deep_merge(second) ⇒ Object



15
16
17
18
# File 'lib/reqres_rspec/utils.rb', line 15

def deep_merge(second)
  merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
  self.merge(second, &merger)
end

#deep_merge!(second) ⇒ Object



20
21
22
23
# File 'lib/reqres_rspec/utils.rb', line 20

def deep_merge!(second)
  merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
  self.merge!(second, &merger)
end