Class: Hanami::CLI::CommandRegistry::Node Private
- Inherits:
-
Object
- Object
- Hanami::CLI::CommandRegistry::Node
- Defined in:
- lib/hanami/cli/command_registry.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.
Node of the registry
Instance Attribute Summary collapse
- #after_callbacks ⇒ Object readonly private
- #aliases ⇒ Object readonly private
- #before_callbacks ⇒ Object readonly private
- #children ⇒ Object readonly private
- #command ⇒ Object readonly private
- #parent ⇒ Object readonly private
Instance Method Summary collapse
- #alias!(key, child) ⇒ Object private
- #aliases!(aliases) ⇒ Object private
-
#initialize(parent = nil) ⇒ Node
constructor
private
A new instance of Node.
- #leaf!(command) ⇒ Object private
- #leaf? ⇒ Boolean private
- #lookup(token) ⇒ Object private
- #put(parent, key) ⇒ Object private
Constructor Details
#initialize(parent = nil) ⇒ 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.
110 111 112 113 114 115 116 117 118 |
# File 'lib/hanami/cli/command_registry.rb', line 110 def initialize(parent = nil) @parent = parent @children = Concurrent::Hash.new @aliases = Concurrent::Hash.new @command = nil @before_callbacks = Utils::Callbacks::Chain.new @after_callbacks = Utils::Callbacks::Chain.new end |
Instance Attribute Details
#after_callbacks ⇒ 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.
106 107 108 |
# File 'lib/hanami/cli/command_registry.rb', line 106 def after_callbacks @after_callbacks end |
#aliases ⇒ 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.
94 95 96 |
# File 'lib/hanami/cli/command_registry.rb', line 94 def aliases @aliases end |
#before_callbacks ⇒ 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.
102 103 104 |
# File 'lib/hanami/cli/command_registry.rb', line 102 def before_callbacks @before_callbacks end |
#children ⇒ 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.
90 91 92 |
# File 'lib/hanami/cli/command_registry.rb', line 90 def children @children end |
#command ⇒ 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.
98 99 100 |
# File 'lib/hanami/cli/command_registry.rb', line 98 def command @command end |
#parent ⇒ 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.
86 87 88 |
# File 'lib/hanami/cli/command_registry.rb', line 86 def parent @parent end |
Instance Method Details
#alias!(key, child) ⇒ 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.
140 141 142 |
# File 'lib/hanami/cli/command_registry.rb', line 140 def alias!(key, child) @aliases[key] = child end |
#aliases!(aliases) ⇒ 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.
146 147 148 149 150 |
# File 'lib/hanami/cli/command_registry.rb', line 146 def aliases!(aliases) aliases.each do |a| parent.alias!(a, self) end end |
#leaf!(command) ⇒ 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.
134 135 136 |
# File 'lib/hanami/cli/command_registry.rb', line 134 def leaf!(command) @command = command 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.
154 155 156 |
# File 'lib/hanami/cli/command_registry.rb', line 154 def leaf? !command.nil? end |
#lookup(token) ⇒ 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.
128 129 130 |
# File 'lib/hanami/cli/command_registry.rb', line 128 def lookup(token) children[token] || aliases[token] end |
#put(parent, key) ⇒ 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.
122 123 124 |
# File 'lib/hanami/cli/command_registry.rb', line 122 def put(parent, key) children[key] ||= self.class.new(parent) end |