Class: DatabaseCleaner::DataMapper::Transaction

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/database_cleaner/data_mapper/transaction.rb

Instance Method Summary collapse

Methods included from Base

#db, #db=

Methods included from Generic::Base

#db, included

Instance Method Details

#clean(repository = self.db) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/database_cleaner/data_mapper/transaction.rb', line 15

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

#start(repository = self.db) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/database_cleaner/data_mapper/transaction.rb', line 7

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