Module: Skywalker::Transactional

Included in:
Command
Defined in:
lib/skywalker/transactional.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Requires Acceptable and add accessors for callbacks.

Since:

  • 2.2.0



11
12
13
14
# File 'lib/skywalker/transactional.rb', line 11

def self.included(klass)
  klass.include Acceptable
  klass.send(:attr_accessor, :on_success, :on_failure, :error)
end

Instance Method Details

#callObject

Runs the transaction and all operations.

Since:

  • 2.2.0



22
23
24
25
26
27
28
29
30
31
# File 'lib/skywalker/transactional.rb', line 22

def call
  transaction do
    execute!

    confirm_success
  end

rescue Exception => error
  confirm_failure error
end