Class: Hanami::Middleware::Node Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/middleware/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 to register scopes with custom Rack middleware

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



16
17
18
19
# File 'lib/hanami/middleware/node.rb', line 16

def initialize
  @app = nil
  @children = {}
end

Instance Attribute Details

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



12
13
14
# File 'lib/hanami/middleware/node.rb', line 12

def app
  @app
end

Instance Method Details

#app!(app) ⇒ 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



42
43
44
# File 'lib/hanami/middleware/node.rb', line 42

def app!(app)
  @app = app
end

#app?Boolean

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:

  • (Boolean)

Since:

  • 2.0.0



48
49
50
# File 'lib/hanami/middleware/node.rb', line 48

def app?
  !@app.nil?
end

#freezeObject

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



23
24
25
26
# File 'lib/hanami/middleware/node.rb', line 23

def freeze
  @children.freeze
  super
end

#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



36
37
38
# File 'lib/hanami/middleware/node.rb', line 36

def get(segment)
  @children.fetch(segment) { self if leaf? }
end

#leaf?Boolean

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:

  • (Boolean)

Since:

  • 2.0.0



54
55
56
# File 'lib/hanami/middleware/node.rb', line 54

def leaf?
  @children.empty?
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



30
31
32
# File 'lib/hanami/middleware/node.rb', line 30

def put(segment)
  @children[segment] ||= self.class.new
end