From 0fedae636ed1e8c4c63e8e6a25644c8838f3613a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 17 Jul 2015 14:42:57 -0700 Subject: push fields_for_style? in to a protected method this way we don't need to call `to_unsafe_h` to get access to ask questions about the underlying hash --- actionpack/lib/action_controller/metal/strong_parameters.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller/metal') diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 1f10fb3bbe..06d625e4d5 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -540,6 +540,10 @@ module ActionController @permitted = new_permitted end + def fields_for_style? + @parameters.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) } + end + private def new_instance_with_inherited_permitted_status(hash) self.class.new(hash).tap do |new_instance| @@ -570,7 +574,7 @@ module ActionController when Array object.grep(Parameters).map { |el| yield el }.compact when Parameters - if fields_for_style?(object) + if object.fields_for_style? hash = object.class.new object.each { |k,v| hash[k] = yield v } hash @@ -580,10 +584,6 @@ module ActionController end end - def fields_for_style?(object) - object.to_unsafe_h.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) } - end - def unpermitted_parameters!(params) unpermitted_keys = unpermitted_keys(params) if unpermitted_keys.any? -- cgit v1.2.3