Class: DatabaseFlusher::Mongoid::DeletionStrategy
- Inherits:
-
Object
- Object
- DatabaseFlusher::Mongoid::DeletionStrategy
- Defined in:
- lib/database_flusher/mongoid/deletion_strategy.rb
Defined Under Namespace
Classes: Subscriber
Instance Attribute Summary collapse
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
Instance Method Summary collapse
- #clean ⇒ Object
- #clean_all ⇒ Object
-
#initialize ⇒ DeletionStrategy
constructor
A new instance of DeletionStrategy.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ DeletionStrategy
Returns a new instance of DeletionStrategy.
25 26 27 |
# File 'lib/database_flusher/mongoid/deletion_strategy.rb', line 25 def initialize @collections = Set.new end |
Instance Attribute Details
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
5 6 7 |
# File 'lib/database_flusher/mongoid/deletion_strategy.rb', line 5 def collections @collections end |
Instance Method Details
#clean ⇒ Object
40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
49 50 51 52 53 |
# 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 ⇒ Object
29 30 31 32 33 34 |
# File 'lib/database_flusher/mongoid/deletion_strategy.rb', line 29 def start @subscriber ||= client.subscribe( Mongo::Monitoring::COMMAND, Subscriber.new(self) ) end |
#stop ⇒ Object
36 37 38 |
# File 'lib/database_flusher/mongoid/deletion_strategy.rb', line 36 def stop raise NotImplementedError, "Mongo doesn't provide unsubscribe" end |