Class: DatabaseCleaner::DataMapper::Transaction

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

Instance Method Summary collapse

Methods included from Generic::Transaction

#initialize

Methods included from Base

#db, #db=

Methods included from Generic::Base

#cleaning, #db, included

Instance Method Details

#clean(repository = self.db) ⇒ Object



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

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



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

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