Class: Hanami::Router::Leaf

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/router/leaf.rb

Overview

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Since:

  • 2.2.0



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

Since:

  • 2.2.0



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

Since:

  • 2.2.0



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.

Since:

  • 2.2.0



28
29
30
# File 'lib/hanami/router/leaf.rb', line 28

def match(path)
  matcher.match(path)&.named_captures
end