diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-15 14:34:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-15 14:34:37 -0700 |
commit | fe19d07138fe69e05ce8b17534c3c548a0a92575 (patch) | |
tree | 9785a62bcc259bcdd98b349134ccbebacc99effc | |
parent | 703275ba70efbefb3358052b6ba750443eff1a28 (diff) | |
download | rails-fe19d07138fe69e05ce8b17534c3c548a0a92575.tar.gz rails-fe19d07138fe69e05ce8b17534c3c548a0a92575.tar.bz2 rails-fe19d07138fe69e05ce8b17534c3c548a0a92575.zip |
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.
-rw-r--r-- | actionpack/lib/action_dispatch/journey/routes.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 12 |
2 files changed, 13 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/journey/routes.rb b/actionpack/lib/action_dispatch/journey/routes.rb index 4770b8b7cc..f7b009109e 100644 --- a/actionpack/lib/action_dispatch/journey/routes.rb +++ b/actionpack/lib/action_dispatch/journey/routes.rb @@ -61,14 +61,7 @@ module ActionDispatch 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! diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f82c3c0d34..a9dae77e51 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -143,6 +143,18 @@ module ActionDispatch @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 |