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
20
21
# File 'lib/hanami/router/leaf.rb', line 16

def initialize(route, to, constraints)
  @route = route
  @to = to
  @constraints = constraints
  @params = nil
end

Instance Attribute Details

#paramsObject (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 params
  @params
end

#toObject (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.

Since:

  • 2.2.0



25
26
27
28
29
30
31
# File 'lib/hanami/router/leaf.rb', line 25

def match(path)
  match = matcher.match(path)

  @params = match.named_captures if match

  match
end