From 93a391e7863102a77991fc019bb5b9b4158ec759 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 18 Sep 2015 11:24:13 -0700 Subject: remove the `default` parameter from the parser method since there is only one "default" strategy now, we can just use the block parameter for that. --- actionpack/lib/action_dispatch/http/request.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 68a8ca707a..232006895f 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -348,11 +348,8 @@ module ActionDispatch # Override Rack's POST method to support indifferent access def POST fetch_header("action_dispatch.request.request_parameters") do - default = ->() { + pr = parse_formatted_parameters(self, params_parsers) do |params| Request::Utils.normalize_encode_params(super || {}) - } - pr = parse_formatted_parameters(self, params_parsers, default) do |params| - params end self.request_parameters = pr end @@ -400,12 +397,12 @@ module ActionDispatch name end - def parse_formatted_parameters(request, parsers, default = ->() { nil }) - return default.call if request.content_length.zero? + def parse_formatted_parameters(request, parsers) + return yield if request.content_length.zero? - strategy = parsers.fetch(request.content_mime_type) { return default.call } + strategy = parsers.fetch(request.content_mime_type) { return yield } - yield strategy.call(request.raw_post) + strategy.call(request.raw_post) rescue Rack::QueryParser::InvalidParameterError raise -- cgit v1.2.3