Sha256: 91141404102b63755b2f5c587f7dfbc212778c3128593797f0d4eef87ac06e45

Contents?: true

Size: 628 Bytes

Versions: 8

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true
module DatabaseFlusher
  module ActiveRecord
    class TransactionStrategy
      def start
        # Hack to make sure that the connection is properly setup for
        # the clean code.
        ::ActiveRecord::Base.connection.transaction{ }

        ::ActiveRecord::Base.connection.begin_transaction joinable: false
      end

      def stop
        ::ActiveRecord::Base.connection_pool.connections.each do |connection|
          next unless connection.open_transactions > 0
          connection.rollback_transaction
        end
      end

      def clean
        stop
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
database_flusher-0.3.4 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.3.3 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.3.2 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.3.1 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.3.0 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.2.3 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.2.2 lib/database_flusher/active_record/transaction_strategy.rb
database_flusher-0.2.1 lib/database_flusher/active_record/transaction_strategy.rb