Skip to content

Commit 2df8e86

Browse files
committed
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
1 parent 55d0e6f commit 2df8e86

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

actionpack/lib/action_controller/metal/strong_parameters.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,9 @@ def array_of_permitted_scalars?(value)
648648
end
649649
end
650650

651-
def array_of_permitted_scalars_filter(params, key)
652-
if array_of_permitted_scalars?(self[key])
653-
params[key] = self[key]
651+
def array_of_permitted_scalars_filter(value)
652+
if array_of_permitted_scalars?(value)
653+
yield value
654654
end
655655
end
656656

@@ -665,7 +665,9 @@ def hash_filter(params, filter)
665665

666666
if filter[key] == EMPTY_ARRAY
667667
# Declaration { comment_ids: [] }.
668-
array_of_permitted_scalars_filter(params, key)
668+
array_of_permitted_scalars_filter(self[key]) do |val|
669+
params[key] = val
670+
end
669671
else
670672
# Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
671673
params[key] = each_element(value) do |element|

0 commit comments

Comments
 (0)