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.



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

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.



8
9
10
# File 'lib/action_dispatch/journey/nodes/node.rb', line 8

def names
  @names
end

#path_paramsObject (readonly)

Returns the value of attribute path_params.



8
9
10
# File 'lib/action_dispatch/journey/nodes/node.rb', line 8

def path_params
  @path_params
end

#terminalsObject (readonly)

Returns the value of attribute terminals.



8
9
10
# File 'lib/action_dispatch/journey/nodes/node.rb', line 8

def terminals
  @terminals
end

#treeObject (readonly) Also known as: root

Returns the value of attribute tree.



8
9
10
# File 'lib/action_dispatch/journey/nodes/node.rb', line 8

def tree
  @tree
end

#wildcard_optionsObject (readonly)

Returns the value of attribute wildcard_options.



8
9
10
# File 'lib/action_dispatch/journey/nodes/node.rb', line 8

def wildcard_options
  @wildcard_options
end

Instance Method Details

#glob?Boolean

Returns:

  • (Boolean)


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

def glob?
  stars.any?
end

#requirements=(requirements) ⇒ Object



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

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



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

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