diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-08-03 13:54:44 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-08-03 13:54:44 +0100 |
commit | f6124c2b09aed7b5951d0ac83438459c49757a36 (patch) | |
tree | 37ced4d11eafdb81f5173ae8b08e6124d3fee03c /actionpack/lib/action_controller/routing/builder.rb | |
parent | acd0456fcf251d1e50cbf08311341dfd370dc1aa (diff) | |
parent | cb21db1a334e6ca2695d4e7183b1bdce204b9eb3 (diff) | |
download | rails-f6124c2b09aed7b5951d0ac83438459c49757a36.tar.gz rails-f6124c2b09aed7b5951d0ac83438459c49757a36.tar.bz2 rails-f6124c2b09aed7b5951d0ac83438459c49757a36.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_controller/routing/builder.rb')
-rw-r--r-- | actionpack/lib/action_controller/routing/builder.rb | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/actionpack/lib/action_controller/routing/builder.rb b/actionpack/lib/action_controller/routing/builder.rb index 912999d845..03427e41de 100644 --- a/actionpack/lib/action_controller/routing/builder.rb +++ b/actionpack/lib/action_controller/routing/builder.rb @@ -48,14 +48,10 @@ module ActionController end when /\A\*(\w+)/ then PathSegment.new($1.to_sym, :optional => true) when /\A\?(.*?)\?/ - returning segment = StaticSegment.new($1) do - segment.is_optional = true - end + StaticSegment.new($1, :optional => true) when /\A(#{separator_pattern(:inverted)}+)/ then StaticSegment.new($1) when Regexp.new(separator_pattern) then - returning segment = DividerSegment.new($&) do - segment.is_optional = (optional_separators.include? $&) - end + DividerSegment.new($&, :optional => (optional_separators.include? $&)) end [segment, $~.post_match] end @@ -176,29 +172,16 @@ module ActionController defaults, requirements, conditions = divide_route_options(segments, options) requirements = assign_route_options(segments, defaults, requirements) - route = Route.new - - route.segments = segments - route.requirements = requirements - route.conditions = conditions + # TODO: Segments should be frozen on initialize + segments.each { |segment| segment.freeze } - if !route.significant_keys.include?(:action) && !route.requirements[:action] - route.requirements[:action] = "index" - route.significant_keys << :action - end - - # Routes cannot use the current string interpolation method - # if there are user-supplied <tt>:requirements</tt> as the interpolation - # code won't raise RoutingErrors when generating - if options.key?(:requirements) || route.requirements.keys.to_set != Routing::ALLOWED_REQUIREMENTS_FOR_OPTIMISATION - route.optimise = false - end + route = Route.new(segments, requirements, conditions) if !route.significant_keys.include?(:controller) raise ArgumentError, "Illegal route: the :controller must be specified!" end - route + route.freeze end private |