aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-17 14:08:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-17 14:08:12 -0700
commit89448a7f5c21729568eaa12250447f313197a30d (patch)
tree97da227a52022521c0963c3439df961f357c8f2a /actionpack/lib/action_controller/metal/strong_parameters.rb
parentcb3f25593b1137e344086364d4b1a52c08e8eb3b (diff)
downloadrails-89448a7f5c21729568eaa12250447f313197a30d.tar.gz
rails-89448a7f5c21729568eaa12250447f313197a30d.tar.bz2
rails-89448a7f5c21729568eaa12250447f313197a30d.zip
remove useless conditionals
`element` can never be a hash because: 1. `slice` returns a Parameters object and calls each on it: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L656 2. `each` which is implemented by `each_pair` will call `convert_hashes_to_parameters` on the value: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L192-197 3. `convert_hashes_to_parameters` will convert any hash objects in to parameters objects: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L550-566
Diffstat (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index cfff3190b9..3a585ae29a 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -578,7 +578,7 @@ module ActionController
end
def fields_for_style?(object)
- (object.is_a?(Hash) || object.is_a?(Parameters)) &&
+ object.is_a?(Parameters) &&
object.to_unsafe_h.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) }
end
@@ -665,7 +665,7 @@ module ActionController
else
# Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
params[key] = each_element(value) do |element|
- if element.is_a?(Hash) || element.is_a?(Parameters)
+ if element.is_a?(Parameters)
element = self.class.new(element) unless element.respond_to?(:permit)
element.permit(*Array.wrap(filter[key]))
end