Class: Opera::Operation::Instructions::Executors::Transaction

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

Defined Under Namespace

Classes: RollbackTransactionError

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



10
11
12
13
14
15
16
17
18
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 10

def call(instruction)
  transaction_wrapper do
    super

    raise(transaction_error) if result.failure?
  end
rescue transaction_error
  nil
end

#transaction_classObject



26
27
28
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 26

def transaction_class
  config.transaction_class
end

#transaction_errorObject



38
39
40
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 38

def transaction_error
  RollbackTransactionError
end

#transaction_methodObject



30
31
32
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 30

def transaction_method
  config.transaction_method
end

#transaction_optionsObject



34
35
36
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 34

def transaction_options
  config.transaction_options
end

#transaction_wrapperObject



20
21
22
23
24
# File 'lib/opera/operation/instructions/executors/transaction.rb', line 20

def transaction_wrapper
  return transaction_class.send(transaction_method) { yield } unless transaction_options

  transaction_class.send(transaction_method, **transaction_options) { yield }
end