method
build_path
rails latest stable - Class:
ActionDispatch::Routing::Mapper::Mapping
build_path(ast, requirements, anchor)private
No documentation available.
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 196
def build_path(ast, requirements, anchor)
pattern = Journey::Path::Pattern.new(ast, requirements, JOINED_SEPARATORS, anchor)
# Find all the symbol nodes that are adjacent to literal nodes and alter
# the regexp so that Journey will partition them into custom routes.
ast.find_all { |node|
next unless node.cat?
if node.left.literal? && node.right.symbol?
symbol = node.right
elsif node.left.literal? && node.right.cat? && node.right.left.symbol?
symbol = node.right.left
elsif node.left.symbol? && node.right.literal?
symbol = node.left
elsif node.left.symbol? && node.right.cat? && node.right.left.literal?
symbol = node.left
else
next
end
if symbol
symbol.regexp = /(?:#{Regexp.union(symbol.regexp, '-')})+/
end
}
pattern
end