aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
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 /actionpack/lib/action_controller/metal/strong_parameters.rb
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 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 1190e0ed69..baf15570d5 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -667,6 +667,7 @@ module ActionController
other_hash.to_h.merge(@parameters)
)
end
+ alias_method :with_defaults, :reverse_merge
# Returns current <tt>ActionController::Parameters</tt> instance with
# current hash merged into +other_hash+.
@@ -674,6 +675,7 @@ module ActionController
@parameters.merge!(other_hash.to_h) { |key, left, right| left }
self
end
+ alias_method :with_defaults!, :reverse_merge!
# This is required by ActiveModel attribute assignment, so that user can
# pass +Parameters+ to a mass assignment methods in a model. It should not