Class: CacheAdvance::ActiveRecordSweeper

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
lib/cache_advance/active_record_sweeper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize_observed(classes) ⇒ Object



8
9
10
# File 'lib/cache_advance/active_record_sweeper.rb', line 8

def self.initialize_observed(classes)
  observe(classes)
end

Instance Method Details

#after_create(object) ⇒ Object Also known as: after_update, after_destroy



18
19
20
# File 'lib/cache_advance/active_record_sweeper.rb', line 18

def after_create(object)
  expire_caches_for(object)
end

#reload_sweeperObject



12
13
14
15
16
# File 'lib/cache_advance/active_record_sweeper.rb', line 12

def reload_sweeper
  observed_classes.each do |klass| 
    klass.name.constantize.add_observer(self)
  end
end