diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-21 15:04:19 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-21 15:04:19 -0700 |
commit | c75153d280e70e501c9044286ff52e50fe29a054 (patch) | |
tree | 732fddf0371cbaeeedf56491be1e57ad5d25b44f /actionpack/lib/action_controller/metal | |
parent | d333dd5eb2b64d9b41c34d7a76e18228fb25b1f0 (diff) | |
download | rails-c75153d280e70e501c9044286ff52e50fe29a054.tar.gz rails-c75153d280e70e501c9044286ff52e50fe29a054.tar.bz2 rails-c75153d280e70e501c9044286ff52e50fe29a054.zip |
rearrange logic to use positive branches
only hashes are converted to parameter objects, so lets add a branch for
them. This also removes a is_a? test for Parameters so we can be
abstracted from the class.
Diffstat (limited to 'actionpack/lib/action_controller/metal')
-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 cf6a64009f..7aa61cff07 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -562,14 +562,16 @@ module ActionController end def convert_value_to_parameters(value) - if value.is_a?(Array) && !converted_arrays.member?(value) + case value + when Array + return value if converted_arrays.member?(value) converted = value.map { |_| convert_value_to_parameters(_) } converted_arrays << converted converted - elsif value.is_a?(Parameters) || !value.is_a?(Hash) - value - else + when Hash self.class.new(value) + else + value end end |