Sha256: 76514626140a8b89da1a5e65a154b40d0266e22b491495b7956821bb8799764a

Contents?: true

Size: 756 Bytes

Versions: 48

Compression:

Stored size: 756 Bytes

Contents

require 'database_cleaner/data_mapper/base'
require 'database_cleaner/generic/transaction'

module DatabaseCleaner::DataMapper
  class Transaction
    include ::DatabaseCleaner::DataMapper::Base
    include ::DatabaseCleaner::Generic::Transaction

    def start(repository = self.db)
      ::DataMapper.repository(repository) do |r|
        transaction = DataMapper::Transaction.new(r)
        transaction.begin
        r.adapter.push_transaction(transaction)
      end
    end

    def clean(repository = self.db)
      ::DataMapper.repository(repository) do |r|
        adapter = r.adapter
        while adapter.current_transaction
          adapter.current_transaction.rollback
          adapter.pop_transaction
        end
      end
    end

  end
end

Version data entries

48 entries across 43 versions & 7 rubygems

Version Path
database_cleaner-1.99.0 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.99.0.beta adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-data_mapper-1.99.0.beta lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.5 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.4 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.3 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.2 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.1 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.0 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-data_mapper-1.8.0 lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.8.0.beta adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-data_mapper-1.8.0.beta lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.7.0 lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.6.2 lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.6.1 lib/database_cleaner/data_mapper/transaction.rb
database_cleaner-1.6.0 lib/database_cleaner/data_mapper/transaction.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/data_mapper/transaction.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/data_mapper/transaction.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/data_mapper/transaction.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/data_mapper/transaction.rb