Class: CacherObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/observers/cacher_observer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clear_cacheObject



21
22
23
24
25
26
# File 'app/observers/cacher_observer.rb', line 21

def clear_cache
  Rails.cache.clear

  FileUtils.rm_rf Dir[Rails.root.join('tmp', 'file_cache', 'pages', '**/*').to_s]
  FileUtils.rm_rf Dir[Rails.root.join('public', 'cache', '**/*').to_s]
end

Instance Method Details

#after_create(_record) ⇒ Object



7
8
9
# File 'app/observers/cacher_observer.rb', line 7

def after_create(_record)
  self.class.clear_cache
end

#after_destroy(_record) ⇒ Object



15
16
17
# File 'app/observers/cacher_observer.rb', line 15

def after_destroy(_record)
  self.class.clear_cache
end

#after_update(_record) ⇒ Object



11
12
13
# File 'app/observers/cacher_observer.rb', line 11

def after_update(_record)
  self.class.clear_cache
end