Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/hash.rb

Instance Method Summary collapse

Instance Method Details

#reverse_merge(other_hash) ⇒ Object

Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second.



3
4
5
# File 'lib/extensions/hash.rb', line 3

def reverse_merge(other_hash)
  other_hash.merge(self)
end

#reverse_merge!(other_hash) ⇒ Object

Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. Modifies the receiver in place.



9
10
11
# File 'lib/extensions/hash.rb', line 9

def reverse_merge!(other_hash)
  replace(reverse_merge(other_hash))
end