Class: ActionDispatch::Journey::Ast

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/journey/nodes/node.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tree, formatted) ⇒ Ast

Returns a new instance of Ast.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/action_dispatch/journey/nodes/node.rb', line 13

def initialize(tree, formatted)
  @tree = tree
  @path_params = []
  @names = []
  @symbols = []
  @stars = []
  @terminals = []
  @wildcard_options = {}

  visit_tree(formatted)
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



10
11
12
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10

def names
  @names
end

#path_paramsObject (readonly)

Returns the value of attribute path_params.



10
11
12
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10

def path_params
  @path_params
end

#terminalsObject (readonly)

Returns the value of attribute terminals.



10
11
12
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10

def terminals
  @terminals
end

#treeObject (readonly) Also known as: root

Returns the value of attribute tree.



10
11
12
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10

def tree
  @tree
end

#wildcard_optionsObject (readonly)

Returns the value of attribute wildcard_options.



10
11
12
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10

def wildcard_options
  @wildcard_options
end

Instance Method Details

#glob?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/action_dispatch/journey/nodes/node.rb', line 38

def glob?
  stars.any?
end

#requirements=(requirements) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/action_dispatch/journey/nodes/node.rb', line 25

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

#route=(route) ⇒ Object



34
35
36
# File 'lib/action_dispatch/journey/nodes/node.rb', line 34

def route=(route)
  terminals.each { |n| n.memo = route }
end