Class: DatabaseCleaner::DataMapper::Truncation

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

Instance Method Summary collapse

Methods included from Generic::Truncation

included

Methods included from Base

#db, #db=

Methods included from Generic::Base

included

Instance Method Details

#clean(repository = nil) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 151

def clean(repository = nil)
  repository = self.db if repository.nil?
  adapter = ::DataMapper.repository(repository).adapter
  adapter.disable_referential_integrity do
    tables_to_truncate(repository).each do |table_name|
      adapter.truncate_table table_name
    end
  end
end