class ActionDispatch::Routing::Mapper::Mapping

def default_controller_and_action(to_shorthand=nil)

def default_controller_and_action(to_shorthand=nil)
  if to.respond_to?(:call)
    { }
  else
    if to.is_a?(String)
      controller, action = to.split('#')
    elsif to.is_a?(Symbol)
      action = to.to_s
    end
    controller ||= default_controller
    action     ||= default_action
    unless controller.is_a?(Regexp) || to_shorthand
      controller = [@scope[:module], controller].compact.join("/").presence
    end
    controller = controller.to_s unless controller.is_a?(Regexp)
    action     = action.to_s     unless action.is_a?(Regexp)
    if controller.blank? && segment_keys.exclude?("controller")
      raise ArgumentError, "missing :controller"
    end
    if action.blank? && segment_keys.exclude?("action")
      raise ArgumentError, "missing :action"
    end
    { :controller => controller, :action => action }.tap do |hash|
      hash.delete(:controller) if hash[:controller].blank?
      hash.delete(:action)     if hash[:action].blank?
    end
  end
end