Module: DatabaseCleaner::ConnectionAdapters::AbstractMysqlAdapter

Defined in:
lib/database_cleaner/active_record/truncation.rb

Instance Method Summary collapse

Instance Method Details

#pre_count_truncate_tables(tables, options = {:reset_ids => true}) ⇒ Object



53
54
55
56
# File 'lib/database_cleaner/active_record/truncation.rb', line 53

def pre_count_truncate_tables(tables, options = {:reset_ids => true})
  filter = options[:reset_ids] ? method(:has_been_used?) : method(:has_rows?)
  truncate_tables(tables.select(&filter))
end

#truncate_table(table_name) ⇒ Object



45
46
47
# File 'lib/database_cleaner/active_record/truncation.rb', line 45

def truncate_table(table_name)
  execute("TRUNCATE TABLE #{quote_table_name(table_name)};")
end

#truncate_tables(tables) ⇒ Object



49
50
51
# File 'lib/database_cleaner/active_record/truncation.rb', line 49

def truncate_tables(tables)
  tables.each { |t| truncate_table(t) }
end