Method: Hash#reverse_merge
- Defined in:
- activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
#reverse_merge(other_hash) ⇒ Object Also known as: with_defaults
Merges the caller into other_hash. For example,
= .reverse_merge(size: 25, velocity: 10)
is equivalent to
= { size: 25, velocity: 10 }.merge()
This is particularly useful for initializing an options hash with default values.
14 15 16 |
# File 'activesupport/lib/active_support/core_ext/hash/reverse_merge.rb', line 14 def reverse_merge(other_hash) other_hash.merge(self) end |