diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-22 23:52:02 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-22 23:52:02 +0100 |
commit | 21b80f8144f8f05a105b2989c79d3ed2f2d0d4cd (patch) | |
tree | bfec5946303ceb582674904c5f9927e9b4020272 /actionpack/lib/action_controller/routing | |
parent | 91ab75373f13054485f5d804d7e2c80d466ff5e0 (diff) | |
parent | 441e4e22352c8805a882f6a661ab3982dd7eda12 (diff) | |
download | rails-21b80f8144f8f05a105b2989c79d3ed2f2d0d4cd.tar.gz rails-21b80f8144f8f05a105b2989c79d3ed2f2d0d4cd.tar.bz2 rails-21b80f8144f8f05a105b2989c79d3ed2f2d0d4cd.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_controller/routing')
-rw-r--r-- | actionpack/lib/action_controller/routing/segments.rb | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index 5dda3d4d00..129e87c139 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -191,23 +191,19 @@ module ActionController end def regexp_chunk - if regexp - if regexp_has_modifiers? - "(#{regexp.to_s})" - else - "(#{regexp.source})" - end - else - "([^#{Routing::SEPARATORS.join}]+)" - end + regexp ? regexp_string : default_regexp_chunk + end + + def regexp_string + regexp_has_modifiers? ? "(#{regexp.to_s})" : "(#{regexp.source})" + end + + def default_regexp_chunk + "([^#{Routing::SEPARATORS.join}]+)" end def number_of_captures - if regexp - regexp.number_of_captures + 1 - else - 1 - end + regexp ? regexp.number_of_captures + 1 : 1 end def build_pattern(pattern) @@ -244,10 +240,6 @@ module ActionController "(?i-:(#{(regexp || Regexp.union(*possible_names)).source}))" end - def number_of_captures - 1 - end - # Don't URI.escape the controller name since it may contain slashes. def interpolation_chunk(value_code = local_name) "\#{#{value_code}.to_s}" @@ -289,8 +281,8 @@ module ActionController "params[:#{key}] = PathSegment::Result.new_escaped((match[#{next_capture}]#{" || " + default.inspect if default}).split('/'))#{" if match[" + next_capture + "]" if !default}" end - def regexp_chunk - regexp || "(.*)" + def default_regexp_chunk + "(.*)" end def number_of_captures |