Class: ActionDispatch::Journey::Ast
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/journey/nodes/node.rb |
Class Method Summary
- .new(tree, formatted) ⇒ Ast constructor
Instance Attribute Summary
- #glob? ⇒ Boolean readonly
- #names readonly
- #path_params readonly
- #requirements=(requirements) writeonly
-
#root
readonly
Alias for #tree.
- #route=(route) writeonly
- #terminals readonly
- #tree (also: #root) readonly
- #wildcard_options readonly
- #stars readonly private
- #symbols readonly private
Instance Method Summary
- #visit_tree(formatted) private
Constructor Details
.new(tree, formatted) ⇒ Ast
# File 'actionpack/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
#glob? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 38
def glob? stars.any? end
#names (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 10
attr_reader :names, :path_params, :tree, :, :terminals
#path_params (readonly)
[ GitHub ]#requirements=(requirements) (writeonly)
[ GitHub ]# File 'actionpack/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
#root (readonly)
Alias for #tree.
#route=(route) (writeonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 34
def route=(route) terminals.each { |n| n.memo = route } end
#stars (readonly, private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 43
attr_reader :symbols, :stars
#symbols (readonly, private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 43
attr_reader :symbols, :stars
#terminals (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 10
attr_reader :names, :path_params, :tree, :, :terminals
#tree (readonly) Also known as: #root
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 10
attr_reader :names, :path_params, :tree, :, :terminals
#wildcard_options (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 10
attr_reader :names, :path_params, :tree, :, :terminals
Instance Method Details
#visit_tree(formatted) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/nodes/node.rb', line 45
def visit_tree(formatted) tree.each do |node| if node.symbol? path_params << node.to_sym names << node.name symbols << node elsif node.star? stars << node if formatted != false # Add a constraint for wildcard route to make it non-greedy and match the # optional format part of the route by default. [node.name.to_sym] ||= /.+?/m end end if node.terminal? terminals << node end end end