class ActionDispatch::Routing::RouteSet::Generator

:nodoc:

def controller

def controller
  @controller ||= @options[:controller]
end

def current_controller

def current_controller
  @recall[:controller]
end

def different_controller?

def different_controller?
  return false unless current_controller
  controller.to_param != current_controller.to_param
end

def generate

def generate
  path, params = @set.formatter.generate(:path_info, named_route, options, recall, PARAMETERIZE)
  raise_routing_error unless path
  return [path, params.keys] if @extras
  [path, params]
rescue Journey::Router::RoutingError
  raise_routing_error
end

def handle_nil_action!

It is identical to :action => "index"
This handles the case of :action => nil being explicitly passed.
def handle_nil_action!
  if options.has_key?(:action) && options[:action].nil?
    options[:action] = 'index'
  end
  recall[:action] = options.delete(:action) if options[:action] == 'index'
end

def initialize(options, recall, set, extras = false)

def initialize(options, recall, set, extras = false)
  @named_route = options.delete(:use_route)
  @options     = options.dup
  @recall      = recall.dup
  @set         = set
  @extras      = extras
  normalize_options!
  normalize_controller_action_id!
  use_relative_controller!
  controller.sub!(%r{^/}, '') if controller
  handle_nil_action!
end

def named_route_exists?

def named_route_exists?
  named_route && set.named_routes[named_route]
end

def normalize_controller_action_id!

more keys from the recall.
:controller, :action or :id is not found, don't pull any
or if the key in the options is identical. If any of
The recall key is only used if there is no key in the options
This pulls :controller, :action, and :id out of the recall.
def normalize_controller_action_id!
  @recall[:action] ||= 'index' if current_controller
  use_recall_for(:controller) or return
  use_recall_for(:action) or return
  use_recall_for(:id)
end

def normalize_options!

def normalize_options!
  # If an explicit :controller was given, always make :action explicit
  # too, so that action expiry works as expected for things like
  #
  #   generate({:controller => 'content'}, {:controller => 'content', :action => 'show'})
  #
  # (the above is from the unit tests). In the above case, because the
  # controller was explicitly given, but no action, the action is implied to
  # be "index", not the recalled action of "show".
  if options[:controller]
    options[:action]     ||= 'index'
    options[:controller]   = options[:controller].to_s
  end
  if options[:action]
    options[:action] = options[:action].to_s
  end
end

def raise_routing_error

def raise_routing_error
  raise ActionController::RoutingError, "No route matches #{options.inspect}"
end

def segment_keys

def segment_keys
  set.named_routes[named_route].segment_keys
end

def use_recall_for(key)

def use_recall_for(key)
  if @recall[key] && (!@options.key?(key) || @options[key] == @recall[key])
    if named_route_exists?
      @options[key] = @recall.delete(key) if segment_keys.include?(key)
    else
      @options[key] = @recall.delete(key)
    end
  end
end

def use_relative_controller!

is specified, the controller becomes "foo/baz/bat"
if the current controller is "foo/bar/baz" and :controller => "baz/bat"
def use_relative_controller!
  if !named_route && different_controller? && !controller.start_with?("/")
    old_parts = current_controller.split('/')
    size = controller.count("/") + 1
    parts = old_parts[0...-size] << controller
    @controller = @options[:controller] = parts.join("/")
  end
end