提交 5046d517 编写于 作者: A Aaron Patterson

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.
上级 c75153d2
......@@ -378,16 +378,14 @@ def []=(key, value)
# 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 @@ def transform_keys!(&block)
# 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 @@ def new_instance_with_inherited_permitted_status(hash)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册