提交 3c03e7e2 编写于 作者: A Aaron Patterson

swtich to returning early if to responds to call

上级 ac9a3a9d
......@@ -237,47 +237,44 @@ def app
end
def default_controller_and_action
if to.respond_to?(:call)
{ }
else
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("/").presence
end
end
hash = {}
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 controller.is_a? Regexp
hash[:controller] = controller
if @scope[:module] && !controller.is_a?(Regexp)
if controller =~ %r{\A/}
controller = controller[1..-1]
else
check_controller! controller
hash[:controller] = controller.to_s if controller
controller = [@scope[:module], controller].compact.join("/").presence
end
end
if action.is_a? Regexp
hash[:action] = action
else
check_action! action
hash[:action] = action.to_s if action
end
if controller.is_a? Regexp
hash[:controller] = controller
else
check_controller! controller
hash[:controller] = controller.to_s if controller
end
hash
if action.is_a? Regexp
hash[:action] = action
else
check_action! action
hash[:action] = action.to_s if action
end
hash
end
def check_action!(action)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册