Class: Hanami::API::Middleware::Node Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/api/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:

  • 0.1.1

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:

  • 0.1.1



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

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:

  • 0.1.1



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

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:

  • 0.1.1



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

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.

Since:

  • 0.1.1



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

def app?
  @app
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:

  • 0.1.1



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

def freeze
  @children.each(&: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:

  • 0.1.1



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

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.

Since:

  • 0.1.1



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

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:

  • 0.1.1



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

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