diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 16:34:36 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-28 16:34:36 -0700 |
commit | 309ff10d7d895ccb822b426dac3fb0a41e1da193 (patch) | |
tree | ee272db42449471a6b54bc3fa144292ebc2c6f72 /actionpack | |
parent | a729f4050766f97750dd006217a175229b09da34 (diff) | |
download | rails-309ff10d7d895ccb822b426dac3fb0a41e1da193.tar.gz rails-309ff10d7d895ccb822b426dac3fb0a41e1da193.tar.bz2 rails-309ff10d7d895ccb822b426dac3fb0a41e1da193.zip |
only one nil check on the action variable
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 72edf6725c..5ea694f0ff 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -259,11 +259,16 @@ module ActionDispatch end end - if action.is_a? Regexp + case action + when Regexp hash[:action] = action + when String, Symbol + hash[:action] = action.to_s else - check_action! action - hash[:action] = action.to_s if action + unless segment_keys.include?(:action) + message = "Missing :action key on routes definition, please check your routes." + raise ArgumentError, message + end end hash @@ -289,13 +294,6 @@ module ActionDispatch [controller, action] end - def check_action!(action) - unless action || segment_keys.include?(:action) - message = "Missing :action key on routes definition, please check your routes." - raise ArgumentError, message - end - end - def check_controller!(controller) return controller if controller =~ /\A[a-z_0-9][a-z_0-9\/]*\z/ |