123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Journey::Path::Pattern::AnchoredRegexp

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActionDispatch::Journey::Visitors::Visitor
Defined in: actionpack/lib/action_dispatch/journey/path/pattern.rb

Constant Summary

::ActionDispatch::Journey::Visitors::Visitor - Inherited

DISPATCH_CACHE

Class Method Summary

Instance Method Summary

Constructor Details

.new(separator, matchers) ⇒ AnchoredRegexp

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 69

def initialize(separator, matchers)
  @separator = separator
  @matchers  = matchers
  @separator_re = "([^#{separator}]+)"
  super()
end

Instance Method Details

#accept(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 76

def accept(node)
  %r{\A#{visit node}\Z}
end

#visit_CAT(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 80

def visit_CAT(node)
  "#{visit(node.left)}#{visit(node.right)}"
end

#visit_DOT(node)

Alias for #visit_LITERAL.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 100

alias :visit_DOT :visit_LITERAL

#visit_GROUP(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 93

def visit_GROUP(node)
  "(?:#{visit node.left})?"
end

#visit_LITERAL(node) Also known as: #visit_DOT

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 97

def visit_LITERAL(node)
  Regexp.escape(node.left)
end

#visit_OR(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 111

def visit_OR(node)
  children = node.children.map { |n| visit n }
  "(?:#{children.join(?|)})"
end

#visit_SLASH(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 102

def visit_SLASH(node)
  node.left
end

#visit_STAR(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 106

def visit_STAR(node)
  re = @matchers[node.left.to_sym]
  re ? "(#{re})" : "(.+)"
end

#visit_SYMBOL(node)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/path/pattern.rb', line 84

def visit_SYMBOL(node)
  node = node.to_sym

  return @separator_re unless @matchers.key?(node)

  re = @matchers[node]
  "(#{Regexp.union(re)})"
end