Sha256: ed19a3f42ca8a14879eae43b749560b4f225cf04c42f5fd3049636d0b5ba236a
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
Contents
class PageSweeper < ActionController::Caching::Sweeper observe Page, Slug def after_save model expire_cache model end def after_destroy model expire_cache model end private def expire_cache model case model.class.name.to_s when "Page" # only expire latest slug # in case title changes, it will trigger the expire_slug function from the observer purge "/#{model.slug.name}" # expire all cache if we change root page purge nil, true if (model.root?) when "Slug" # expire from parent level down expire_parent_and_descendants model end end private # expire the parent directory and page def expire_parent_and_descendants slug purge parent_slug(slug), true end def parent_slug slug if slug.sluggable_type == "Page" if slug.sluggable.root? slug else slug.sluggable.parent.slug.name end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-varnish-pages-0.0.1 | lib/sweepers/page_sweeper.rb |