Module: ActiveInteraction::Transactable

Extended by:
ActiveSupport::Concern
Included in:
Runnable
Defined in:
lib/active_interaction/concerns/transactable.rb

Overview

Execute code in a transaction. If ActiveRecord isn’t available, don’t do anything special.

Since:

  • 1.2.0

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#transaction { ... } ⇒ Object

Yields:

Since:

  • 1.2.0



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_interaction/concerns/transactable.rb', line 29

def transaction
  return unless block_given?

  if self.class.transaction?
    ActiveRecord::Base.transaction(self.class.transaction_options) do
      yield
    end
  else
    yield
  end
end