diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-08 14:38:46 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-12 16:50:48 -0700 |
commit | 59b9fe961d2195b35f3934dc6228a248897656e6 (patch) | |
tree | 4c73aa2ffd9e7bdc54a147b81c87caef3ef667e1 /actionpack | |
parent | 4ffe667ab7713a7cd926803655719b2a399615ce (diff) | |
download | rails-59b9fe961d2195b35f3934dc6228a248897656e6.tar.gz rails-59b9fe961d2195b35f3934dc6228a248897656e6.tar.bz2 rails-59b9fe961d2195b35f3934dc6228a248897656e6.zip |
reuse the route collection and formatter by clearing them
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 3883ac7c60..2419e09ee0 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -228,6 +228,13 @@ module ActionDispatch @append = [] @prepend = [] @disable_clear_and_finalize = false + + @set = Journey::Routes.new + @router = Journey::Router.new(@set, { + :parameters_key => PARAMETERS_KEY, + :request_class => request_class}) + @formatter = Journey::Formatter.new @set + clear! end @@ -270,11 +277,8 @@ module ActionDispatch @finalized = false routes.clear named_routes.clear - @set = Journey::Routes.new - @router = Journey::Router.new(@set, { - :parameters_key => PARAMETERS_KEY, - :request_class => request_class}) - @formatter = Journey::Formatter.new @set + set.clear + formatter.clear @prepend.each { |blk| eval_block(blk) } end @@ -343,7 +347,7 @@ module ActionDispatch def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i) route = Route.new(self, app, conditions, requirements, defaults, name, anchor) - @set.add_route(route.app, route.conditions, route.defaults, route.name) + @set.add_route(app, route.conditions, defaults, name) named_routes[name] = route if name routes << route route |