Class: DatabaseCleaner::Mongo::Deletion

Inherits:
Strategy
  • Object
show all
Defined in:
lib/database_cleaner/mongo/deletion.rb

Instance Method Summary collapse

Constructor Details

#initialize(only: [], except: [], cache_tables: nil) ⇒ Deletion

Returns a new instance of Deletion.



8
9
10
11
12
13
14
# File 'lib/database_cleaner/mongo/deletion.rb', line 8

def initialize only: [], except: [], cache_tables: nil
  @only = only
  @except = except
  if !cache_tables.nil?
    DatabaseCleaner.deprecate "The mongo adapter's :cache_tables option has no effect, and will be removed in database_cleaner-mongo 3.0."
  end
end

Instance Method Details

#cleanObject



20
21
22
# File 'lib/database_cleaner/mongo/deletion.rb', line 20

def clean
  collections_to_delete.each(&:delete_many)
end

#dbObject



16
17
18
# File 'lib/database_cleaner/mongo/deletion.rb', line 16

def db
  @db || raise("You have not specified a database.  (see Mongo::Database)")
end