The Formatter class is used for formatting URLs. For example, parameters passed to url_for in rails will eventually call Formatter#generate
# File lib/journey/formatter.rb, line 13 def generate key, name, options, recall = {}, parameterize = nil constraints = recall.merge options match_route(name, constraints) do |route| data = constraints.dup keys_to_keep = route.parts.reverse.drop_while { |part| !options.key?(part) || (options[part] || recall[part]).nil? } | route.required_parts (data.keys - keys_to_keep).each do |bad_key| data.delete bad_key end parameterized_parts = data.dup if parameterize parameterized_parts.each do |k,v| parameterized_parts[k] = parameterize.call(k, v) end end parameterized_parts.keep_if { |_,v| v } next if !name && route.requirements.empty? && route.parts.empty? next unless verify_required_parts!(route, parameterized_parts) z = Hash[options.to_a - data.to_a - route.defaults.to_a] return [route.format(parameterized_parts), z] end raise Router::RoutingError end
Generated with the Darkfish Rdoc Generator 2.