aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-17 16:43:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-17 16:43:40 -0700
commitc989e2c56f415e0a4429b1348e76be4fc8e9f35b (patch)
tree1b02a29d2fcdaf4b8c77060a8e02d1b9d0f34676 /actionpack/lib/action_dispatch/routing
parentbb1003080259b3c6cb974e5c9d55a561a9530cbb (diff)
downloadrails-c989e2c56f415e0a4429b1348e76be4fc8e9f35b.tar.gz
rails-c989e2c56f415e0a4429b1348e76be4fc8e9f35b.tar.bz2
rails-c989e2c56f415e0a4429b1348e76be4fc8e9f35b.zip
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.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb24
1 files 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: