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

def initialize(route, to, constraints)
  @to = to
  @params = nil
  @matcher = Mustermann.new(route, type: :rails, version: "5.0", capture: constraints)
end

Instance Attribute Details

#matcherObject (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

#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



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

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

  @params = match.named_captures if match

  match
end