2007-01-22 07:43:50 -06:00
|
|
|
require_dependency 'cache_sweeping_helper'
|
|
|
|
|
|
|
|
class WebSweeper < ActionController::Caching::Sweeper
|
|
|
|
|
|
|
|
include CacheSweepingHelper
|
|
|
|
|
2009-01-10 22:33:30 -06:00
|
|
|
observe Web, Page, WikiFile
|
2007-01-22 07:43:50 -06:00
|
|
|
|
|
|
|
def after_save(record)
|
2008-12-29 10:17:35 -06:00
|
|
|
if record.is_a?(Web)
|
|
|
|
web = record
|
|
|
|
web.pages.each { |page| expire_cached_page(web, page.name) }
|
|
|
|
expire_cached_summary_pages(web)
|
2009-01-10 22:33:30 -06:00
|
|
|
elsif record.is_a?(WikiFile)
|
2009-06-02 22:17:15 -05:00
|
|
|
record.web.pages_that_link_to_file(record.file_name).each do |page|
|
2009-01-10 22:33:30 -06:00
|
|
|
expire_cached_page(record.web, page)
|
|
|
|
end
|
|
|
|
expire_cached_summary_pages(record.web)
|
2008-12-29 10:17:35 -06:00
|
|
|
end
|
2007-01-22 07:43:50 -06:00
|
|
|
end
|
2008-10-27 01:47:01 -05:00
|
|
|
|
2008-12-29 10:17:35 -06:00
|
|
|
def after_destroy(record)
|
|
|
|
if record.is_a?(Web)
|
|
|
|
expire_cached_summary_pages(record)
|
2009-01-10 22:33:30 -06:00
|
|
|
elsif record.is_a?(Page)
|
2008-12-29 10:17:35 -06:00
|
|
|
expire_cached_page(record.web, record.name)
|
2009-01-01 02:38:12 -06:00
|
|
|
expire_cached_summary_pages(record.web)
|
2009-03-31 23:37:21 -05:00
|
|
|
expire_cached_revisions(record)
|
2009-01-10 22:33:30 -06:00
|
|
|
else
|
|
|
|
expire_cached_summary_pages(record.web)
|
2008-12-29 10:17:35 -06:00
|
|
|
end
|
|
|
|
end
|
2008-12-06 16:11:47 -06:00
|
|
|
|
2007-01-22 07:43:50 -06:00
|
|
|
end
|