Class: GitCommander::Command::Runner Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/git_commander/command/runner.rb

Overview

This class is 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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Runner

Returns a new instance of Runner.



14
15
16
# File 'lib/git_commander/command/runner.rb', line 14

def initialize(command)
  @command = command
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



32
33
34
35
36
# 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

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/git_commander/command/runner.rb', line 10

def command
  @command
end

Instance Method Details

#respond_to_missing?(method_sym, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# 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 = {}) ⇒ Object



18
19
20
21
# 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) ⇒ Object



23
24
25
# File 'lib/git_commander/command/runner.rb', line 23

def say(message)
  command.say message
end