Class: Lite::Command::Procedure

Inherits:
Complex
  • Object
show all
Includes:
Extensions::Errors
Defined in:
lib/lite/command/procedure.rb

Instance Attribute Summary collapse

Attributes inherited from Complex

#result

Instance Method Summary collapse

Methods included from Extensions::Errors

#errored?, #errors, #fail!, #failure?, included, #merge_errors!, #merge_exception!, #result!, #status, #success?, #validate!

Methods inherited from Complex

call, #call, #called?, execute, #initialize, #recall!

Constructor Details

This class inherits a constructor from Lite::Command::Complex

Instance Attribute Details

#exit_on_failureObject

Returns the value of attribute exit_on_failure.



9
10
11
# File 'lib/lite/command/procedure.rb', line 9

def exit_on_failure
  @exit_on_failure
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lite/command/procedure.rb', line 11

def execute
  steps.each_with_object([]) do |command, results|
    command.call

    if respond_to?(:errors) && command.respond_to?(:errors) && command.failure?
      merge_errors!(command)
      break results if exit_on_failure?
    else
      results << command.result
    end
  end
end

#exit_on_failure?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/lite/command/procedure.rb', line 24

def exit_on_failure?
  @exit_on_failure ||= false
end

#stepsObject



28
29
30
# File 'lib/lite/command/procedure.rb', line 28

def steps
  @steps ||= @args.flatten
end