aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-17 13:32:10 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-17 13:36:33 -0700
commit2df8e86caf35d6f85d6b4fe260ddd247bbe6772a (patch)
tree3f22d98466e8aa36d55624e8b6a81678015bbd7c /actionpack/lib
parent55d0e6f87719bb9a7040d59db7e5beaa6701e55e (diff)
downloadrails-2df8e86caf35d6f85d6b4fe260ddd247bbe6772a.tar.gz
rails-2df8e86caf35d6f85d6b4fe260ddd247bbe6772a.tar.bz2
rails-2df8e86caf35d6f85d6b4fe260ddd247bbe6772a.zip
stop passing `params` to `array_of_permitted_scalars_filter`
this way the method doesn't have to know what the new params object is, it just yields to a block. This change also caches the value of `self[key]` on the stack
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index a989641cdb..03639c1835 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -648,9 +648,9 @@ module ActionController
end
end
- def array_of_permitted_scalars_filter(params, key)
- if array_of_permitted_scalars?(self[key])
- params[key] = self[key]
+ def array_of_permitted_scalars_filter(value)
+ if array_of_permitted_scalars?(value)
+ yield value
end
end
@@ -665,7 +665,9 @@ module ActionController
if filter[key] == EMPTY_ARRAY
# Declaration { comment_ids: [] }.
- array_of_permitted_scalars_filter(params, key)
+ array_of_permitted_scalars_filter(self[key]) do |val|
+ params[key] = val
+ end
else
# Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
params[key] = each_element(value) do |element|