Class: Hanami::Middleware::Node Private
- Inherits:
-
Object
- Object
- Hanami::Middleware::Node
- 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
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.
16 17 18 19 |
# File 'lib/hanami/middleware/node.rb', line 16 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.
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.
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.
48 49 50 |
# File 'lib/hanami/middleware/node.rb', line 48 def app? !@app.nil? 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.
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.
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.
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.
30 31 32 |
# File 'lib/hanami/middleware/node.rb', line 30 def put(segment) @children[segment] ||= self.class.new end |