Sha256: e35a0f3ff7ac3ffbb6445e0b71ea011d7d34aa10be54b5b6674019d4f0234ddd

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
database_flusher-0.2.0 lib/database_flusher/active_record/transaction_strategy.rb