aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-03-29 17:23:47 -0400
committerGitHub <noreply@github.com>2017-03-29 17:23:47 -0400
commitd5a2e8baa924ba6194ad4e6ae118b4d1ca19c342 (patch)
tree8851deb0159ed80f6258db9a88f014cef9bfec9e /activesupport/lib
parentf77a6be8d23f048ced4fac54f1f4caea5e0749d7 (diff)
parent0117810cdab34d168b0579a6736c5d58c5ab84c7 (diff)
downloadrails-d5a2e8baa924ba6194ad4e6ae118b4d1ca19c342.tar.gz
rails-d5a2e8baa924ba6194ad4e6ae118b4d1ca19c342.tar.bz2
rails-d5a2e8baa924ba6194ad4e6ae118b4d1ca19c342.zip
Merge pull request #28603 from mikeastock/alias-reverse-merge
Add an alias for reverse_merge to with_defaults
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/reverse_merge.rb2
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb2
2 files changed, 4 insertions, 0 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 efb9d1b8a0..061c959442 100644
--- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
+++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
@@ -12,6 +12,7 @@ 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)
@@ -19,4 +20,5 @@ class Hash
merge!(other_hash) { |key, left, right| left }
end
alias_method :reverse_update, :reverse_merge!
+ alias_method :with_defaults!, :reverse_merge!
end
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index 1927cddf34..1e1d6d3aac 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -225,11 +225,13 @@ module ActiveSupport
def reverse_merge(other_hash)
super(self.class.new(other_hash))
end
+ alias_method :with_defaults, :reverse_merge
# Same semantics as +reverse_merge+ but modifies the receiver in-place.
def reverse_merge!(other_hash)
replace(reverse_merge(other_hash))
end
+ alias_method :with_defaults!, :reverse_merge!
# Replaces the contents of this hash with other_hash.
#