aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-21 15:10:14 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-21 15:10:14 -0700
commit5046d5179e9627bb84962f7ebf2153bfac6db254 (patch)
tree5430f812b9d6b42744038650e9e624ba5b049342
parentc75153d280e70e501c9044286ff52e50fe29a054 (diff)
downloadrails-5046d5179e9627bb84962f7ebf2153bfac6db254.tar.gz
rails-5046d5179e9627bb84962f7ebf2153bfac6db254.tar.bz2
rails-5046d5179e9627bb84962f7ebf2153bfac6db254.zip
drop conditionals in conversion logic
there is no reason to `convert_hashes_to_parameters` with an assignemt flag. The caller knows whether or not it wants the value assigned. We should just change the uncommon case (not writing to the underlying hash) to just call the conversion method and return that value.
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 7aa61cff07..e78f1f0d7e 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -378,16 +378,14 @@ module ActionController
# params.fetch(:none, 'Francesco') # => "Francesco"
# params.fetch(:none) { 'Francesco' } # => "Francesco"
def fetch(key, *args, &block)
- convert_hashes_to_parameters(
- key,
+ convert_value_to_parameters(
@parameters.fetch(key) {
if block_given?
yield
else
args.fetch(0) { raise ActionController::ParameterMissing.new(key) }
end
- },
- false
+ }
)
end
@@ -475,7 +473,7 @@ module ActionController
# optional code block is given and the key is not found, pass in the key
# and return the result of block.
def delete(key, &block)
- convert_hashes_to_parameters(key, @parameters.delete(key), false)
+ convert_value_to_parameters(@parameters.delete(key))
end
# Returns a new instance of <tt>ActionController::Parameters</tt> with only
@@ -555,9 +553,9 @@ module ActionController
end
end
- def convert_hashes_to_parameters(key, value, assign_if_converted=true)
+ def convert_hashes_to_parameters(key, value)
converted = convert_value_to_parameters(value)
- @parameters[key] = converted if assign_if_converted && !converted.equal?(value)
+ @parameters[key] = converted unless converted.equal?(value)
converted
end