1 class DiarySweeper < ActionController::Caching::Sweeper
2 observe DiaryComment, DiaryEntry
4 def after_create(record)
5 expire_cache_for(record)
8 def after_update(record)
9 expire_cache_for(record)
12 def after_destroy(record)
13 expire_cache_for(record)
18 def expire_cache_for(record)
20 when record.is_a?(DiaryEntry): entry = record
21 when record.is_a?(DiaryComment): entry = record.diary_entry
24 expire_action(:controller => 'diary_entry', :action => 'view', :display_name => entry.user.display_name, :id => entry.id)
26 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => nil)
27 expire_action(:controller => 'diary_entry', :action => 'list', :language => entry.language_code, :display_name => nil)
28 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => entry.user.display_name)
30 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => nil)
31 expire_action(:controller => 'diary_entry', :action => 'rss', :language => entry.language_code, :display_name => nil)
32 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => entry.user.display_name)