diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 14:52:17 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 15:15:44 -0700 |
commit | 1ad50aa37939da41714409bf249dcb208dba3c75 (patch) | |
tree | 2b7c5cb523468a780ca818313e563747d1a614b1 | |
parent | e135bbacb9316ec6f1cad18548952816150ac927 (diff) | |
download | rails-1ad50aa37939da41714409bf249dcb208dba3c75.tar.gz rails-1ad50aa37939da41714409bf249dcb208dba3c75.tar.bz2 rails-1ad50aa37939da41714409bf249dcb208dba3c75.zip |
set defaults at the top so we can avoid the ||= test
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 84a08770f5..68f9225a45 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -240,15 +240,18 @@ module ActionDispatch if to.respond_to?(:call) { } else - if to.is_a?(String) - controller, action = to.split('#') - elsif to.is_a?(Symbol) + controller = default_controller + action = default_action + + case to + when Symbol action = to.to_s + when /#/ + controller, action = to.split('#') + when String + controller = to end - controller ||= default_controller - action ||= default_action - if @scope[:module] && !controller.is_a?(Regexp) if controller =~ %r{\A/} controller = controller[1..-1] |