class GitCommander::Command::Configurator

Allows configuring a [GitCommander::Command] with a block

Attributes

registry[R]

Public Class Methods

new(registry) click to toggle source
# File lib/git_commander/command/configurator.rb, line 11
def initialize(registry)
  @registry = registry
end

Public Instance Methods

configure(name, &block) click to toggle source
# 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.message)
  configuration_error.set_backtrace e.backtrace
  raise configuration_error
end