Class: GitCommander::Command::Runner Abstract
- Inherits:
-
Object
- Object
- GitCommander::Command::Runner
- 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
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(command) ⇒ Runner
constructor
A new instance of Runner.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
- #respond_to_missing?(method_sym, include_all = false) ⇒ Boolean
- #run(options = {}) ⇒ Object
- #say(message) ⇒ Object
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
#command ⇒ Object (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
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( = {}) GitCommander.logger.info "Running '#{command.name}' with arguments: #{options.inspect}" instance_exec(, &command.block) end |
#say(message) ⇒ Object
23 24 25 |
# File 'lib/git_commander/command/runner.rb', line 23 def say() command.say end |