From 05eea6a2c3fc4a2eeec04819abedc0c5a909d63c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Aug 2015 18:11:00 -0700 Subject: only process `via` once we can directly turn it in to a regular expression here, so we don't need to test its value twice --- actionpack/lib/action_dispatch/routing/mapper.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d80faf7423..f82c3c0d34 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -109,6 +109,7 @@ module ActionDispatch @default_action = default_action @ast = ast @anchor = anchor + @via = via path_params = ast.find_all(&:symbol?).map(&:to_sym) @@ -140,9 +141,6 @@ module ActionDispatch @defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults(options)) @required_defaults = (split_options[:required_defaults] || []).map(&:first) - unless via == [:all] - @conditions[:request_method] = via.map { |m| m.to_s.dasherize.upcase } - end end def application @@ -164,8 +162,8 @@ module ActionDispatch # :request_method represents the HTTP verb that matches this route. # # Here we munge values before they get sent on to rack-mount. - verbs = conditions[:request_method] || [] - unless verbs.empty? + unless @via == [:all] + verbs = @via.map { |m| m.to_s.dasherize.upcase } conditions[:request_method] = %r[^#{verbs.join('|')}$] end -- cgit v1.2.3