Module: BetterService::Concerns::Serviceable::Transactional::ClassMethods

Defined in:
lib/better_service/concerns/serviceable/transactional.rb

Instance Method Summary collapse

Instance Method Details

#with_transaction(value) ⇒ Object

Enable or disable database transactions for this service

Examples:

Enable transactions

class Booking::CreateService < BetterService::CreateService
  with_transaction true
end

Disable transactions

class Booking::ImportService < BetterService::CreateService
  with_transaction false  # Disable inherited transaction
end

Parameters:

  • value (Boolean)

    whether to wrap process in a transaction



38
39
40
# File 'lib/better_service/concerns/serviceable/transactional.rb', line 38

def with_transaction(value)
  self._with_transaction = value
end