class DatabaseFlusher::Mongoid::DeletionStrategy
Attributes
collections[R]
Public Class Methods
new()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 25 def initialize @collections = Set.new end
Public Instance Methods
clean()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 40 def clean return if collections.empty? # puts "Cleaning #{collections.inspect}" collections.each do |name| client[name].delete_many end collections.clear end
clean_all()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 49 def clean_all all_collections.each do |name| client[name].delete_many end end
start()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 29 def start @subscriber ||= client.subscribe( Mongo::Monitoring::COMMAND, Subscriber.new(self) ) end
stop()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 36 def stop raise NotImplementedError, "Mongo doesn't provide unsubscribe" end
Private Instance Methods
all_collections()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 61 def all_collections client.database.collections.collect { |c| c.namespace.split('.',2)[1] } end
client()
click to toggle source
# File lib/database_flusher/mongoid/deletion_strategy.rb, line 57 def client @client ||= ::Mongoid::Clients.default end