aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorMatt Casper <matthewvcasper@gmail.com>2017-03-29 09:56:27 -0500
committerMichael Stock <mikeastock@gmail.com>2017-03-29 15:55:09 -0500
commit0117810cdab34d168b0579a6736c5d58c5ab84c7 (patch)
tree4021e5a1e5181aa63e189297ac5a97ef135e9580 /activesupport/lib/active_support/core_ext
parent55ccec637212a2232a64f86360b2a25fa1c25759 (diff)
downloadrails-0117810cdab34d168b0579a6736c5d58c5ab84c7.tar.gz
rails-0117810cdab34d168b0579a6736c5d58c5ab84c7.tar.bz2
rails-0117810cdab34d168b0579a6736c5d58c5ab84c7.zip
Add aliases for reverse_merge to with_defaults
In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/reverse_merge.rb2
1 files changed, 2 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