1 class UserSweeper < ActionController::Caching::Sweeper
4 def before_update(record)
5 expire_cache_for(User.find(record.id), record)
8 def before_destroy(record)
9 expire_cache_for(record, nil)
14 def expire_cache_for(old_record, new_record)
17 old_record.visible? != new_record.visible? or
18 old_record.display_name != new_record.display_name or
19 old_record.image != new_record.image)
20 old_record.diary_entries.each do |entry|
21 expire_action(:controller => 'diary_entry', :action => 'view', :display_name => old_record.display_name, :id => entry.id)
22 expire_action(:controller => 'diary_entry', :action => 'list', :language => entry.language_code, :display_name => nil)
23 expire_action(:controller => 'diary_entry', :action => 'rss', :language => entry.language_code, :display_name => nil)
26 old_record.diary_comments.each do |comment|
27 expire_action(:controller => 'diary_entry', :action => 'view', :display_name => comment.diary_entry.user.display_name, :id => comment.diary_entry.id)
30 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => nil)
31 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => old_record.display_name)
33 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => nil)
34 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => old_record.display_name)
36 old_record.traces.each do |trace|
37 expire_action(:controller => 'trace', :action => 'view', :id => trace.id)
38 expire_action(:controller => 'trace', :action => 'view', :display_name => old_record.display_name, :id => trace.id)
40 trace.tags.each do |tag|
41 expire_action(:controller => 'trace', :action => 'list', :display_name => nil, :tag => tag.tag)
42 expire_action(:controller => 'trace', :action => 'list', :display_name => old_record.display_name, :tag => tag.tag)
44 expire_action(:controller => 'trace', :action => 'georss', :display_name => nil, :tag => tag.tag)
45 expire_action(:controller => 'trace', :action => 'georss', :display_name => old_record.display_name, :tag => tag.tag)
49 expire_action(:controller => 'trace', :action => 'list', :display_name => nil, :tag => nil)
50 expire_action(:controller => 'trace', :action => 'list', :display_name => old_record.display_name, :tag => nil)
52 expire_action(:controller => 'trace', :action => 'georss', :display_name => nil, :tag => nil)
53 expire_action(:controller => 'trace', :action => 'georss', :display_name => old_record.display_name, :tag => nil)