Class: GitCommander::Command::Configurator
- Inherits:
-
Object
- Object
- GitCommander::Command::Configurator
- Defined in:
- lib/git_commander/command/configurator.rb
Overview
Allows configuring a [GitCommander::Command] with a block
Defined Under Namespace
Classes: ConfigurationError
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #configure(name, &block) ⇒ Object
-
#initialize(registry) ⇒ Configurator
constructor
A new instance of Configurator.
Constructor Details
#initialize(registry) ⇒ Configurator
Returns a new instance of Configurator.
11 12 13 |
# File 'lib/git_commander/command/configurator.rb', line 11 def initialize(registry) @registry = registry end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
9 10 11 |
# File 'lib/git_commander/command/configurator.rb', line 9 def registry @registry end |
Instance Method Details
#configure(name, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/git_commander/command/configurator.rb', line 15 def configure(name, &block) new_command = GitCommander::Command.new(name, registry: registry) new_command.instance_exec new_command, &block if block_given? new_command rescue StandardError => e configuration_error = ConfigurationError.new(e.) configuration_error.set_backtrace e.backtrace raise configuration_error end |