Module: AyeCommander::Callable::ClassMethods

Included in:
AyeCommander::Command::ClassMethods
Defined in:
lib/aye_commander/callable.rb

Overview

Class Methods defined by callable

Instance Method Summary collapse

Instance Method Details

#call(skip_cleanup: false, **args) ⇒ Object

.call is what the user calls when he wants to run his commands. It is able to receive several named arguments, and a couple of options for specific behavior on how the command must be run.

Options skip_validations: (Handled by validate_arguments)

true      Skips both :receives and :requires argument validations
:requires Skips :requires argument validation
:receives Skips :receives argument validation

skip_cleanup:

true     Skips the result cleanup so it has all the instance variables
         that were declared
:command Returns the command instead of an instance of the result
         class


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aye_commander/callable.rb', line 22

def call(skip_cleanup: false, **args)
  command = new(args)
  validate_arguments(args)
  aborted = abortable do
    call_before_hooks(command)
    around_hooks.any? ? call_around_hooks(command) : command.call
    call_after_hooks(command)
  end
  abortable { call_aborted_hooks(command) } if aborted == :aborted
  result(command, skip_cleanup)
end