aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-28 16:23:17 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-28 16:23:17 -0700
commit8d309832df4a32f3bebbbc7ceae800876cef1174 (patch)
tree310fdc4b5a066f7bbb496deccd1fa77b7d8100d8 /actionpack/lib/action_dispatch/routing/mapper.rb
parentbc916a7e58544c72516d36274e2709d9094a1f29 (diff)
downloadrails-8d309832df4a32f3bebbbc7ceae800876cef1174.tar.gz
rails-8d309832df4a32f3bebbbc7ceae800876cef1174.tar.bz2
rails-8d309832df4a32f3bebbbc7ceae800876cef1174.zip
extract controller and action parsing to a method
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb45
1 files changed, 26 insertions, 19 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 80c3b867bc..aaf5563dce 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -240,25 +240,12 @@ module ActionDispatch
hash = {}
return hash if to.respond_to? :call
- controller = default_controller
- action = default_action
-
- case to
- when Symbol
- action = to.to_s
- when /#/
- controller, action = to.split('#')
- when String
- controller = to
- end
-
- if @scope[:module] && !controller.is_a?(Regexp)
- if controller =~ %r{\A/}
- controller = controller[1..-1]
- else
- controller = [@scope[:module], controller].compact.join("/")
- end
- end
+ controller, action = get_controller_and_action(
+ default_controller,
+ default_action,
+ to,
+ @scope[:module]
+ )
if controller.is_a? Regexp
hash[:controller] = controller
@@ -277,6 +264,26 @@ module ActionDispatch
hash
end
+ def get_controller_and_action(controller, action, to, modyoule)
+ case to
+ when Symbol
+ action = to.to_s
+ when /#/
+ controller, action = to.split('#')
+ when String
+ controller = to
+ end
+
+ if modyoule && !controller.is_a?(Regexp)
+ if controller =~ %r{\A/}
+ controller = controller[1..-1]
+ else
+ controller = [modyoule, controller].compact.join("/")
+ end
+ end
+ [controller, action]
+ end
+
def check_action!(action)
unless action || segment_keys.include?(:action)
message = "Missing :action key on routes definition, please check your routes."