diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-30 15:14:04 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-03 11:33:53 -0700 |
commit | 5029c371fe398c915b0291be7ea54a8937cffa76 (patch) | |
tree | d51a1897812a7053a7898a49d43e33a49f4e920d /actionpack | |
parent | 10c1787b30b041e0676c88df261811e8b9aa4c5d (diff) | |
download | rails-5029c371fe398c915b0291be7ea54a8937cffa76.tar.gz rails-5029c371fe398c915b0291be7ea54a8937cffa76.tar.bz2 rails-5029c371fe398c915b0291be7ea54a8937cffa76.zip |
only do is_a checks on `formatted` once
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7b0784b999..377d09a515 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -110,7 +110,7 @@ module ActionDispatch @conditions[:parsed_path_info] = ast add_request_method(via, @conditions) - normalize_defaults!(options, formatted) + normalize_defaults!(options) end def to_route @@ -177,8 +177,10 @@ module ActionDispatch @requirements[:format] ||= /.+/ elsif Regexp === formatted @requirements[:format] = formatted + @defaults[:format] = nil elsif String === formatted @requirements[:format] = Regexp.compile(formatted) + @defaults[:format] = formatted end end @@ -192,18 +194,12 @@ module ActionDispatch end end - def normalize_defaults!(options, formatted) - options.each do |key, default| + def normalize_defaults!(options) + options.each_pair do |key, default| unless Regexp === default @defaults[key] = default end end - - if Regexp === formatted - @defaults[:format] = nil - elsif String === formatted - @defaults[:format] = formatted - end end def verify_callable_constraint(callable_constraint) |