class DatabaseCleaner::Nobrainer::Deletion

Public Class Methods

new(only: [], except: []) click to toggle source
# File lib/database_cleaner/nobrainer/deletion.rb, line 8
def initialize(only: [], except: [])
  @only = only
  @except = except
end

Public Instance Methods

clean() click to toggle source
# File lib/database_cleaner/nobrainer/deletion.rb, line 13
def clean
  collections_to_delete.each do |table_name|
    NoBrainer.run do |r|
      if db == :default
        r.table(table_name).delete
      else
        r.db(db).table(table_name).delete
      end
    end
  end
end

Private Instance Methods

collections() click to toggle source
# File lib/database_cleaner/nobrainer/deletion.rb, line 27
def collections
  if db == :default
    NoBrainer.run(&:table_list)
  else
    NoBrainer.run { |r| r.db(db).table_list }
  end
end
collections_to_delete() click to toggle source
# File lib/database_cleaner/nobrainer/deletion.rb, line 35
def collections_to_delete
  only = @only.any? ? @only : collections
  only - @except
end