Sha256: d89b7c5e1ddee4ac66d0d1898643943bdef7192c21de984bce684fbfd7e2817e

Contents?: true

Size: 1005 Bytes

Versions: 6

Compression:

Stored size: 1005 Bytes

Contents

require 'active_record/connection_adapters/abstract/transaction'

module Journaled
  module TransactionExt
    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

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

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

    def _journaled_staged_events
      @_journaled_staged_events ||= []
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
journaled-5.3.1 lib/journaled/transaction_ext.rb
journaled-5.3.0 lib/journaled/transaction_ext.rb
journaled-5.2.0 lib/journaled/transaction_ext.rb
journaled-5.1.1 lib/journaled/transaction_ext.rb
journaled-5.1.0 lib/journaled/transaction_ext.rb
journaled-5.0.0 lib/journaled/transaction_ext.rb