Sha256: cfb5431b71b3768e3882fe471afe54343e7b8dba7d13d6712f589e7d020e0859

Contents?: true

Size: 1.21 KB

Versions: 18

Compression:

Stored size: 1.21 KB

Contents

class SpudPostCategorySweeper < ActionController::Caching::Sweeper

  observe SpudPostCategory

  def after_save(record)
    expire_cache_for(record)
  end

  def after_destroy(record)
    expire_cache_for(record)
  end

  private

  def expire_cache_for(record)
    if Spud::Blog.config.enable_action_caching
      SpudPost.find_each do |p|
        if p.is_news && Spud::Blog.config.news_enabled
          expire_action news_post_url(p.url_name)
        elsif Spud::Blog.config.blog_enabled
          expire_action blog_post_url(p.url_name)
        end
      end
      expire_action news_url if Spud::Blog.config.news_enabled
      expire_action blog_url if Spud::Blog.config.blog_enabled
      expire_action spud_blog_sitemap_url
    end
    if Spud::Blog.config.enable_full_page_caching
      SpudPost.find_each do |p|
        if p.is_news && Spud::Blog.config.news_enabled
          expire_page news_post_path(p.url_name)
        elsif Spud::Blog.config.blog_enabled
          expire_page blog_post_path(p.url_name)
        end
      end
      expire_page news_path if Spud::Blog.config.news_enabled
      expire_page blog_path if Spud::Blog.config.blog_enabled
      expire_page spud_blog_sitemap_path(:format => :xml)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
spud_blog-0.8.18 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.17 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.16 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.15 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.14 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.13 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.12 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.11 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.8 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.7 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.6 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.5 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.4 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.3 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.2 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.1 app/models/spud_post_category_sweeper.rb
spud_blog-0.8.0 app/models/spud_post_category_sweeper.rb
spud_blog-0.7.5 app/models/spud_post_category_sweeper.rb