Class: Hanami::Router::Node Private

Inherits:
Object
  • Object
show all
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

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

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.

Since:

  • 2.0.0



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

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

Since:

  • 2.0.0



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.

Since:

  • 2.0.0



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.

Since:

  • 2.0.0



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.

Since:

  • 2.2.0



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.

Since:

  • 2.0.0



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