Module: Fuelcell::Action::Callable
- Included in:
- Command, OptDefinition
- Defined in:
- lib/fuelcell/action/callable.rb
Instance Method Summary collapse
-
#call(opts, args, shell) ⇒ Integer
Executes this command.
-
#callable(value = nil) ⇒ Object
(also: #run)
Both getter and setting for callable object.
- #callable? ⇒ Boolean (also: #runnable?)
Instance Method Details
#call(opts, args, shell) ⇒ Integer
Executes this command.
31 32 33 34 35 36 37 38 |
# File 'lib/fuelcell/action/callable.rb', line 31 def call(opts, args, shell) fail 'command is not be called, callable not assigned' unless callable? begin cast_exit_code callable.call(opts, args, shell) rescue StandardError => e shell.exception e end end |
#callable(value = nil) ⇒ Object Also known as: run
Both getter and setting for callable object. This what the cli will execute when this command is found.
9 10 11 12 13 14 15 16 17 |
# File 'lib/fuelcell/action/callable.rb', line 9 def callable(value = nil) return @callable if value.nil? unless value.respond_to?(:call) fail ArgumentError, 'callable must implement :call' end @callable = value end |
#callable? ⇒ Boolean Also known as: runnable?
20 21 22 |
# File 'lib/fuelcell/action/callable.rb', line 20 def callable? callable.respond_to?(:call) end |