Module: Glueby::AR

Defined in:
lib/glueby/active_record.rb,
lib/glueby/active_record/system_information.rb

Defined Under Namespace

Classes: SystemInformation

Class Method Summary collapse

Class Method Details

.transaction(isolation: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/glueby/active_record.rb', line 8

def transaction(isolation: nil)
  options = { joinable: false, requires_new: true }

  adapter_type = ActiveRecord::Base.connection.adapter_name.downcase

  # SQLite3 does not support transaction isolation level READ COMMITTED.
  if isolation == :read_committed && adapter_type == 'mysql2'
    options[:isolation] = :read_committed
  end

  ActiveRecord::Base.transaction(**options) do
    yield
  end
end