diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-17 13:32:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-17 13:36:33 -0700 |
commit | 2df8e86caf35d6f85d6b4fe260ddd247bbe6772a (patch) | |
tree | 3f22d98466e8aa36d55624e8b6a81678015bbd7c | |
parent | 55d0e6f87719bb9a7040d59db7e5beaa6701e55e (diff) | |
download | rails-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
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 10 |
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| |