Module: SimpleAction::Transactable

Extended by:
ActiveSupport::Concern
Included in:
Service
Defined in:
lib/simple_action/concerns/transactable.rb

Instance Method Summary collapse

Instance Method Details

#transaction { ... } ⇒ Object

Yields:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/simple_action/concerns/transactable.rb', line 23

def transaction
  return unless block_given?

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

#transaction?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/simple_action/concerns/transactable.rb', line 36

def transaction?
  true
end

#transaction_optionsHash

Returns:

  • (Hash)


41
42
43
# File 'lib/simple_action/concerns/transactable.rb', line 41

def transaction_options
  {}
end