From c989e2c56f415e0a4429b1348e76be4fc8e9f35b Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Mon, 17 Aug 2015 16:43:40 -0700
Subject: switch Route constructors and pass in the regexp

We don't need to add and delete from the conditions hash anymore, just
pass the regexp directly to the constructor.
---
 actionpack/lib/action_dispatch/routing/mapper.rb | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index e964bf59e0..42257ac3d7 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -144,12 +144,13 @@ module ActionDispatch
         end
 
         def make_route(name, precedence)
-          route = Journey::Route.build(name,
+          route = Journey::Route.new(name,
                             application,
                             path,
                             conditions,
                             required_defaults,
-                            defaults)
+                            defaults,
+                            request_method)
 
           route.precedence = precedence
           route
@@ -170,20 +171,25 @@ module ActionDispatch
         def build_conditions(current_conditions, request_class)
           conditions = current_conditions.dup
 
+          conditions.keep_if do |k, _|
+            request_class.public_method_defined?(k)
+          end
+        end
+        private :build_conditions
+
+        def request_method
           # Rack-Mount requires that :request_method be a regular expression.
           # :request_method represents the HTTP verb that matches this route.
           #
           # Here we munge values before they get sent on to rack-mount.
-          unless @via == [:all]
+          if @via == [:all]
+            //
+          else
             verbs = @via.map { |m| m.to_s.dasherize.upcase }
-            conditions[:request_method] = %r[^#{verbs.join('|')}$]
-          end
-
-          conditions.keep_if do |k, _|
-            request_class.public_method_defined?(k)
+            %r[^#{verbs.join('|')}$]
           end
         end
-        private :build_conditions
+        private :request_method
 
         JOINED_SEPARATORS = SEPARATORS.join # :nodoc:
 
-- 
cgit v1.2.3