Class: Hanami::Router::Leaf
- Inherits:
-
Object
- Object
- Hanami::Router::Leaf
- Defined in:
- lib/hanami/router/leaf.rb
Overview
Instance Attribute Summary collapse
-
#matcher ⇒ Object
readonly
private
Trie Leaf.
-
#to ⇒ Object
readonly
private
Trie Leaf.
Instance Method Summary collapse
-
#initialize(route, to, constraints) ⇒ Leaf
constructor
private
A new instance of Leaf.
-
#match(path) ⇒ Object
private
Returns the captured params for the given path, or nil if the path doesn't match.
Constructor Details
#initialize(route, to, constraints) ⇒ Leaf
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 Leaf.
16 17 18 19 |
# File 'lib/hanami/router/leaf.rb', line 16 def initialize(route, to, constraints) @to = to @matcher = Mustermann.new(route, type: :rails, version: "5.0", capture: constraints) end |
Instance Attribute Details
#matcher ⇒ 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.
Trie Leaf
12 13 14 |
# File 'lib/hanami/router/leaf.rb', line 12 def matcher @matcher end |
#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.
Trie Leaf
12 13 14 |
# File 'lib/hanami/router/leaf.rb', line 12 def to @to end |
Instance Method Details
#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.
Returns the captured params for the given path, or nil if the path doesn't match.
Leaves are shared across concurrent requests, so the captures are returned rather than stored on the leaf.
28 29 30 |
# File 'lib/hanami/router/leaf.rb', line 28 def match(path) matcher.match(path)&.named_captures end |