1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

drop a conditional by always assigning

We will always make an assignment to the env hash and eliminate a
conditional
This commit is contained in:
Aaron Patterson 2015-07-09 15:12:24 -07:00
parent fabcdc711b
commit a1d7d65f0a

View file

@ -26,20 +26,19 @@ module ActionDispatch
end
def call(env)
if params = parse_formatted_parameters(env)
env["action_dispatch.request.request_parameters"] = params
end
default = env["action_dispatch.request.request_parameters"]
env["action_dispatch.request.request_parameters"] = parse_formatted_parameters(env, default)
@app.call(env)
end
private
def parse_formatted_parameters(env)
def parse_formatted_parameters(env, default)
request = Request.new(env)
return false if request.content_length.zero?
return default if request.content_length.zero?
strategy = @parsers.fetch(request.content_mime_type) { return false }
strategy = @parsers.fetch(request.content_mime_type) { return default }
strategy.call(request.raw_post)