class DatabaseCleaner::MongoMapper::Truncation

Public Instance Methods

clean() click to toggle source
# File lib/database_cleaner/mongo_mapper/truncation.rb, line 10
def clean
  if @only
    collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
  else
    collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
  end
  true
end

Private Instance Methods

collections() click to toggle source
# File lib/database_cleaner/mongo_mapper/truncation.rb, line 21
def collections
  database.collections.select { |c| c.name !~ /^system\./ }
end
database() click to toggle source
# File lib/database_cleaner/mongo_mapper/truncation.rb, line 30
def database
  ::MongoMapper.database
end
truncate_method_name() click to toggle source
# File lib/database_cleaner/mongo_mapper/truncation.rb, line 25
def truncate_method_name
  # This constant only exists in the 2.x series.
  defined?(::Mongo::VERSION) ? :delete_many : :remove
end