Class: DatabaseCleaner::Redis::Truncation

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

Direct Known Subclasses

Ohm::Truncation

Instance Method Summary collapse

Methods included from Generic::Truncation

#initialize, #start

Methods included from Base

#db, #db=

Methods included from Generic::Base

#cleaning, #db, included

Instance Method Details

#cleanObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/database_cleaner/redis/truncation.rb', line 10

def clean
  if @only
    @only.each do |term|
      connection.keys(term).each { |k| connection.del k }
    end
  elsif @tables_to_exclude
    keys_except = []
    @tables_to_exclude.each { |term| keys_except += connection.keys(term) }
    connection.keys.each { |k| connection.del(k) unless keys_except.include?(k) }
  else
    connection.flushdb
  end
  connection.quit unless url == :default
end