From 309ff10d7d895ccb822b426dac3fb0a41e1da193 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 May 2014 16:34:36 -0700 Subject: only one nil check on the action variable --- actionpack/lib/action_dispatch/routing/mapper.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_dispatch') 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/ -- cgit v1.2.3