Flowdock
method

build_path

Importance_0
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: ActionDispatch::Routing::Mapper::Mapping

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v6.0.0) is shown here.

build_path(ast, requirements, anchor) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# 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
Register or log in to add new notes.