Module: Journaled::TransactionExt

Defined in:
lib/journaled/transaction_ext.rb

Instance Method Summary collapse

Instance Method Details

#_journaled_staged_eventsObject



29
30
31
# File 'lib/journaled/transaction_ext.rb', line 29

def _journaled_staged_events
  @_journaled_staged_events ||= []
end

#before_commit_recordsObject



18
19
20
21
22
# File 'lib/journaled/transaction_ext.rb', line 18

def before_commit_records
  super.tap do
    Writer.enqueue!(*_journaled_staged_events) if @run_commit_callbacks
  end
end

#commit_recordsObject



24
25
26
27
# File 'lib/journaled/transaction_ext.rb', line 24

def commit_records
  connection.current_transaction._journaled_staged_events.push(*_journaled_staged_events) unless @run_commit_callbacks
  super
end

#initializeObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/journaled/transaction_ext.rb', line 7

def initialize(*, **)
  super.tap do
    raise TransactionSafetyError, <<~MSG unless instance_variable_defined?(:@run_commit_callbacks)
      Journaled::TransactionExt expects @run_commit_callbacks to be defined on Transaction!
      This is an internal API that may have changed in a recent Rails release.
      If you were not expecting to see this error, please file an issue here:
      https://github.com/Betterment/journaled/issues
    MSG
  end
end