Class: Hanami::Router::Node Private
- Inherits:
-
Object
- Object
- Hanami::Router::Node
- Defined in:
- lib/hanami/router/node.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Trie node
Instance Attribute Summary collapse
- #to ⇒ Object readonly private
Instance Method Summary collapse
- #get(segment) ⇒ Object private
-
#initialize ⇒ Node
constructor
private
A new instance of Node.
- #leaf!(route, to, constraints) ⇒ Object private
- #match(path) ⇒ Object private
- #put(segment) ⇒ Object private
Constructor Details
#initialize ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Node.
18 19 20 21 22 |
# File 'lib/hanami/router/node.rb', line 18 def initialize @variable = nil @fixed = nil @leaves = nil end |
Instance Attribute Details
#to ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/hanami/router/node.rb', line 14 def to @to end |
Instance Method Details
#get(segment) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/hanami/router/node.rb', line 37 def get(segment) @fixed&.fetch(segment, nil) || @variable end |
#leaf!(route, to, constraints) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 |
# File 'lib/hanami/router/node.rb', line 43 def leaf!(route, to, constraints) @leaves ||= [] @leaves << Leaf.new(route, to, constraints) end |
#match(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/hanami/router/node.rb', line 50 def match(path) @leaves&.find { |leaf| leaf.match(path) } end |
#put(segment) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 |
# File 'lib/hanami/router/node.rb', line 26 def put(segment) if variable?(segment) @variable ||= self.class.new else @fixed ||= {} @fixed[segment] ||= self.class.new end end |