Class: Opera::Operation::Instructions::Executors::Operations

Inherits:
Executor
  • Object
show all
Defined in:
lib/opera/operation/instructions/executors/operations.rb

Defined Under Namespace

Classes: WrongOperationsResultError

Instance Attribute Summary

Attributes inherited from Executor

#operation

Instance Method Summary collapse

Methods inherited from Executor

#add_instruction_output, #break_condition, #config, #context, #evaluate_instruction, #evaluate_instructions, #initialize, #production_mode?, #reporter, #result

Constructor Details

This class inherits a constructor from Opera::Operation::Executor

Instance Method Details

#call(instruction) ⇒ Object

rubocop:disable Metrics/MethodLength



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opera/operation/instructions/executors/operations.rb', line 11

def call(instruction)
  instruction[:kind] = :step
  operations_results = super

  return if result.exceptions.any?

  case operations_results
  when Array
    operations_results.each do |operation_result|
      raise_error unless operation_result.is_a?(Opera::Operation::Result)
    end

    failures = operations_results.select(&:failure?)

    if failures.any?
      add_failures(failures)
    else
      add_results(instruction, operations_results)
    end
  else
    raise_error
  end
end