Class: ActionDispatch::Journey::Ast
- Inherits:
-
Object
- Object
- ActionDispatch::Journey::Ast
- Defined in:
- lib/action_dispatch/journey/nodes/node.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#path_params ⇒ Object
readonly
Returns the value of attribute path_params.
-
#terminals ⇒ Object
readonly
Returns the value of attribute terminals.
-
#tree ⇒ Object
(also: #root)
readonly
Returns the value of attribute tree.
-
#wildcard_options ⇒ Object
readonly
Returns the value of attribute wildcard_options.
Instance Method Summary collapse
- #glob? ⇒ Boolean
-
#initialize(tree, formatted) ⇒ Ast
constructor
A new instance of Ast.
- #requirements=(requirements) ⇒ Object
- #route=(route) ⇒ Object
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
#names ⇒ Object (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_params ⇒ Object (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 |
#terminals ⇒ Object (readonly)
Returns the value of attribute terminals.
10 11 12 |
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10 def terminals @terminals end |
#tree ⇒ Object (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_options ⇒ Object (readonly)
Returns the value of attribute wildcard_options.
10 11 12 |
# File 'lib/action_dispatch/journey/nodes/node.rb', line 10 def @wildcard_options end |
Instance Method Details
#glob? ⇒ 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 |