2007-01-22 14:43:50 +01:00
|
|
|
require_dependency 'cache_sweeping_helper'
|
|
|
|
|
|
|
|
class WebSweeper < ActionController::Caching::Sweeper
|
|
|
|
|
|
|
|
include CacheSweepingHelper
|
|
|
|
|
2008-12-29 17:17:35 +01:00
|
|
|
observe Web, Page
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
def after_save(record)
|
2008-12-29 17:17:35 +01:00
|
|
|
if record.is_a?(Web)
|
|
|
|
web = record
|
|
|
|
web.pages.each { |page| expire_cached_page(web, page.name) }
|
|
|
|
expire_cached_summary_pages(web)
|
|
|
|
end
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
|
|
|
def after_remove_orphaned_pages(web)
|
|
|
|
expire_cached_summary_pages(web)
|
|
|
|
end
|
2008-12-06 23:11:47 +01:00
|
|
|
|
|
|
|
def after_remove_orphaned_pages_in_category(web)
|
|
|
|
expire_cached_summary_pages(web)
|
|
|
|
end
|
2008-12-29 17:17:35 +01:00
|
|
|
|
|
|
|
def after_destroy(record)
|
|
|
|
if record.is_a?(Web)
|
|
|
|
expire_cached_summary_pages(record)
|
|
|
|
else
|
|
|
|
expire_cached_page(record.web, record.name)
|
2009-01-01 09:38:12 +01:00
|
|
|
expire_cached_summary_pages(record.web)
|
2008-12-29 17:17:35 +01:00
|
|
|
end
|
|
|
|
end
|
2008-12-06 23:11:47 +01:00
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|