Class: DatabaseFlusher::ActiveRecord::DeletionStrategy
- Inherits:
-
Object
- Object
- DatabaseFlusher::ActiveRecord::DeletionStrategy
- Defined in:
- lib/database_flusher/active_record/deletion_strategy.rb
Defined Under Namespace
Classes: Subscriber
Instance Attribute Summary collapse
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
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
28 29 30 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 28 def initialize @tables = Set.new end |
Instance Attribute Details
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
10 11 12 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 10 def tables @tables end |
Instance Method Details
#clean ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 46 def clean return if tables.empty? # puts "Cleaning #{tables.inspect}" adapter.delete(*tables) tables.clear end |
#clean_all ⇒ Object
55 56 57 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 55 def clean_all adapter.delete(*all_tables) end |
#start ⇒ Object
32 33 34 35 36 37 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 32 def start @subscriber ||= ActiveSupport::Notifications.subscribe( 'sql.active_record', Subscriber.new(self) ) end |
#stop ⇒ Object
39 40 41 42 43 44 |
# File 'lib/database_flusher/active_record/deletion_strategy.rb', line 39 def stop if @subscriber ActiveSupport::Notifications.unsubscribe(@subscriber) @subscriber = nil end end |