Parent

Files

HttpRouter::Generator

Constants

SCHEME_PORTS

Public Class Methods

new(route, paths) click to toggle source
# File lib/http_router/generator.rb, line 53
def initialize(route, paths)
  @route, @paths = route, paths
  @router = @route.router
  @route.generator = self
  @path_generators = @paths.map do |p|
    generator = PathGenerator.new(route, p.is_a?(String) ? p : route.path_for_generation, p.is_a?(Regexp) ? p : nil)
  end
end

Public Instance Methods

each_path() click to toggle source
# File lib/http_router/generator.rb, line 70
def each_path
  @path_generators.each {|p| yield p }
  @path_generators.sort! do |p1, p2|
    p2.param_names.size <=> p1.param_names.size
  end
end
max_param_count() click to toggle source
# File lib/http_router/generator.rb, line 66
def max_param_count
  @max_param_count ||= @path_generators.map{|p| p.param_names.size}.max
end
param_names() click to toggle source
# File lib/http_router/generator.rb, line 62
def param_names
  @param_names ||= @path_generators.map{|path| path.param_names}.flatten.uniq
end
path(*args) click to toggle source
# File lib/http_router/generator.rb, line 85
def path(*args)
  result, extra_params = path_with_params(*args)
  append_querystring(result, extra_params)
end
url(*args) click to toggle source
# File lib/http_router/generator.rb, line 77
def url(*args)
  "#{scheme_port.first}#{url_ns(*args)}"
end
url_ns(*args) click to toggle source
# File lib/http_router/generator.rb, line 81
def url_ns(*args)
  "://#{@route.host || @router.default_host}#{scheme_port.last}#{path(*args)}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.