diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/reverse_merge.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/reverse_merge.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index fbb482435d..ef8d592829 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Hash # Merges the caller into +other_hash+. For example, # @@ -12,11 +14,12 @@ class Hash def reverse_merge(other_hash) other_hash.merge(self) end + alias_method :with_defaults, :reverse_merge # Destructive +reverse_merge+. def reverse_merge!(other_hash) - # right wins if there is no left - merge!( other_hash ){|key,left,right| left } + replace(reverse_merge(other_hash)) end alias_method :reverse_update, :reverse_merge! + alias_method :with_defaults!, :reverse_merge! end |