Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move route allocation to a factory method on the mapping object

I would like to change the signature of the Route constructor.  Since
the mapping object has all the data required to construct a Route
object, move the allocation to a factory method.
  • Loading branch information...
commit fe19d07138fe69e05ce8b17534c3c548a0a92575 1 parent 703275b
@tenderlove tenderlove authored
View
9 actionpack/lib/action_dispatch/journey/routes.rb
@@ -61,14 +61,7 @@ def simulator
end
def add_route(name, mapping)
- route = Route.new(name,
- mapping.application,
- mapping.path,
- mapping.conditions,
- mapping.required_defaults,
- mapping.defaults)
-
- route.precedence = routes.length
+ route = mapping.make_route name, routes.length
routes << route
partition_route(route)
clear_cache!
View
12 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -143,6 +143,18 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for
@required_defaults = (split_options[:required_defaults] || []).map(&:first)
end
+ def make_route(name, precedence)
+ route = Journey::Route.new(name,
+ application,
+ path,
+ conditions,
+ required_defaults,
+ defaults)
+
+ route.precedence = precedence
+ route
+ end
+
def application
app(@blocks)
end
Please sign in to comment.
Something went wrong with that request. Please try again.