class ActionDispatch::Journey::Ast
:nodoc:
:nodoc:
def glob?
def glob? stars.any? end
def initialize(tree, formatted)
def initialize(tree, formatted) @tree = tree @path_params = [] @names = [] @symbols = [] @stars = [] @terminals = [] @wildcard_options = {} visit_tree(formatted) end
def requirements=(requirements)
def requirements=(requirements) # inject any regexp requirements for `star` nodes so they can be # determined nullable, which requires knowing if the regex accepts an # empty string. (symbols + stars).each do |node| re = requirements[node.to_sym] node.regexp = re if re end end
def route=(route)
def route=(route) terminals.each { |n| n.memo = route } end
def visit_tree(formatted)
def visit_tree(formatted) tree.each do |node| if node.symbol? path_params << node.to_sym names << node.name symbols << node elsif node.star? stars << node if formatted != false # Add a constraint for wildcard route to make it non-greedy and # match the optional format part of the route by default. wildcard_options[node.name.to_sym] ||= /.+?/m end end if node.terminal? terminals << node end end end