From a08bee784125d569f63ddd9fa875ae9c5d18b342 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 11 Sep 2011 17:14:29 -0700 Subject: all routes can be stored in the Journey Routes object --- actionpack/lib/action_dispatch/routing/route_set.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 000b2a252f..2947eb3f09 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -206,16 +206,17 @@ module ActionDispatch end end - attr_accessor :formatter, :set, :routes, :named_routes, :default_scope, :router + attr_accessor :formatter, :set, :named_routes, :default_scope, :router attr_accessor :disable_clear_and_finalize, :resources_path_names attr_accessor :default_url_options, :request_class, :valid_conditions + alias :routes :set + def self.default_resources_path_names { :new => 'new', :edit => 'edit' } end def initialize(request_class = ActionDispatch::Request) - self.routes = [] self.named_routes = NamedRouteCollection.new self.resources_path_names = self.class.default_resources_path_names.dup self.default_url_options = {} @@ -274,7 +275,6 @@ module ActionDispatch def clear! @finalized = false - routes.clear named_routes.clear set.clear formatter.clear @@ -346,9 +346,8 @@ 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(app, route.conditions, defaults, name) + route = @set.add_route(app, route.conditions, defaults, name) named_routes[name] = route if name - routes << route route end -- cgit v1.2.3