Sha256: edc32dfc4c68d88a40805650712b90ea5eeff3b3ad78a24f807172da66ad5bd3
Contents?: true
Size: 845 Bytes
Versions: 20
Compression:
Stored size: 845 Bytes
Contents
require "active_record" module NulogyGraphqlApi class TransactionService def execute_in_transaction context = Transaction.new result = nil ActiveRecord::Base.transaction(requires_new: true, joinable: false) do result = yield(context) raise ActiveRecord::Rollback if context.rolledback? end result end class Transaction def initialize @rollback = false end def rollback @rollback = true end def rolledback? @rollback end end # TODO: Move to the spec folder class Dummy attr_reader :transaction def execute_in_transaction @transaction = Transaction.new @was_called = true yield(@transaction) end def was_called? @was_called end end end end
Version data entries
20 entries across 20 versions & 1 rubygems