Class: Hanami::API::Middleware::Node Private
- Inherits:
-
Object
- Object
- Hanami::API::Middleware::Node
- 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
Instance Attribute Summary collapse
- #app ⇒ Object readonly private
Instance Method Summary collapse
- #app!(app) ⇒ Object private
- #app? ⇒ Boolean private
- #freeze ⇒ Object private
- #get(segment) ⇒ Object private
-
#initialize ⇒ Node
constructor
private
A new instance of Node.
- #leaf? ⇒ Boolean private
- #put(segment) ⇒ Object private
Constructor Details
#initialize ⇒ Node
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.
17 18 19 20 |
# File 'lib/hanami/api/middleware/node.rb', line 17 def initialize @app = nil @children = {} end |
Instance Attribute Details
#app ⇒ Object (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.
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.
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.
49 50 51 |
# File 'lib/hanami/api/middleware/node.rb', line 49 def app? @app end |
#freeze ⇒ 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.
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.
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.
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.
31 32 33 |
# File 'lib/hanami/api/middleware/node.rb', line 31 def put(segment) @children[segment] ||= self.class.new end |