Module: Hanami::CLI::Registry
- Defined in:
- lib/hanami/cli/registry.rb
Overview
Registry mixin
Defined Under Namespace
Classes: Prefix
Class Method Summary collapse
- .extended(base) ⇒ Object private
Instance Method Summary collapse
-
#after(command_name, callback = nil, &blk) ⇒ Object
Register an after callback.
-
#before(command_name, callback = nil, &blk) ⇒ Object
Register a before callback.
- #get(arguments) ⇒ Object private
-
#register(name, command = nil, aliases: [], **options) ⇒ Object
Register a command.
Class Method Details
.extended(base) ⇒ 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.
11 12 13 14 15 |
# File 'lib/hanami/cli/registry.rb', line 11 def self.extended(base) base.class_eval do @commands = CommandRegistry.new end end |
Instance Method Details
#after(command_name, callback = nil, &blk) ⇒ Object
Register an after callback.
251 252 253 |
# File 'lib/hanami/cli/registry.rb', line 251 def after(command_name, callback = nil, &blk) command(command_name).after_callbacks.append(&_callback(callback, blk)) end |
#before(command_name, callback = nil, &blk) ⇒ Object
Register a before callback.
165 166 167 |
# File 'lib/hanami/cli/registry.rb', line 165 def before(command_name, callback = nil, &blk) command(command_name).before_callbacks.append(&_callback(callback, blk)) end |
#get(arguments) ⇒ 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.
257 258 259 |
# File 'lib/hanami/cli/registry.rb', line 257 def get(arguments) @commands.get(arguments) end |
#register(name, command = nil, aliases: [], **options) ⇒ Object
Register a command
75 76 77 78 79 80 81 |
# File 'lib/hanami/cli/registry.rb', line 75 def register(name, command = nil, aliases: [], **) if block_given? yield Prefix.new(@commands, name, aliases) else @commands.set(name, command, aliases, **) end end |