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)
19 old_record.diary_entries.each do |entry|
20 expire_action(:controller => 'diary_entry', :action => 'view', :id => entry.id)
21 expire_action(:controller => 'diary_entry', :action => 'list', :language => entry.language_code, :display_name => nil)
22 expire_action(:controller => 'diary_entry', :action => 'rss', :language => entry.language_code, :display_name => nil)
25 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => nil)
26 expire_action(:controller => 'diary_entry', :action => 'list', :language => nil, :display_name => old_record.display_name)
28 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => nil)
29 expire_action(:controller => 'diary_entry', :action => 'rss', :language => nil, :display_name => old_record.display_name)
31 old_record.traces.each do |trace|
32 expire_action(:controller => 'trace', :action => 'view', :id => trace.id)
33 expire_action(:controller => 'trace', :action => 'view', :display_name => old_record.display_name, :id => trace.id)
35 trace.tags.each do |tag|
36 expire_action(:controller => 'trace', :action => 'list', :display_name => nil, :tag => tag.tag)
37 expire_action(:controller => 'trace', :action => 'list', :display_name => old_record.display_name, :tag => tag.tag)
39 expire_action(:controller => 'trace', :action => 'georss', :display_name => nil, :tag => tag.tag)
40 expire_action(:controller => 'trace', :action => 'georss', :display_name => old_record.display_name, :tag => tag.tag)
44 expire_action(:controller => 'trace', :action => 'list', :display_name => nil, :tag => nil)
45 expire_action(:controller => 'trace', :action => 'list', :display_name => old_record.display_name, :tag => nil)
47 expire_action(:controller => 'trace', :action => 'georss', :display_name => nil, :tag => nil)
48 expire_action(:controller => 'trace', :action => 'georss', :display_name => old_record.display_name, :tag => nil)