class GitCommander::Command::Runner

@abstract A container to execute blocks defined in command definitions

Command @block will be executed in this class' context and methods will be delegated based on methods defined here, or in plugins.

Attributes

command[R]

Public Class Methods

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

Public Instance Methods

method_missing(method_sym, *arguments, &block) click to toggle source
Calls superclass method
# File lib/git_commander/command/runner.rb, line 32
def method_missing(method_sym, *arguments, &block)
  return plugin_executor(method_sym) if plugin_executor(method_sym)

  super
end
respond_to_missing?(method_sym, include_all = false) click to toggle source
Calls superclass method
# File lib/git_commander/command/runner.rb, line 27
def respond_to_missing?(method_sym, include_all = false)
  plugin_executor(method_sym).respond_to?(method_sym, include_all) ||
    super(method_sym, include_all)
end
run(options = {}) click to toggle source
# File lib/git_commander/command/runner.rb, line 18
def run(options = {})
  GitCommander.logger.info "Running '#{command.name}' with arguments: #{options.inspect}"
  instance_exec(options, &command.block)
end
say(message) click to toggle source
# File lib/git_commander/command/runner.rb, line 23
def say(message)
  command.say message
end

Private Instance Methods

plugin_executor(plugin_name) click to toggle source
# File lib/git_commander/command/runner.rb, line 40
def plugin_executor(plugin_name)
  @plugin_executor ||= command.registry.find_plugin(plugin_name)&.executor
end