Sha256: e764b3344c3652be0f497116934633c57888e55424d48f6e7b3f281d97390bcd

Contents?: true

Size: 778 Bytes

Versions: 16

Compression:

Stored size: 778 Bytes

Contents

class SpudPostCommentSweeper < ActionController::Caching::Sweeper

  observe SpudPostComment

  def after_save(record)
    expire_cache_for(record)
  end

  def after_destroy(record)
    expire_cache_for(record)
  end

  private

  def expire_cache_for(record)
    unless record.post.nil?
      if Spud::Blog.config.cache_mode == :action
        if record.post.is_news
          expire_action news_post_url(record.post.url_name)
        else
          expire_action blog_post_url(record.post.url_name)
        end
      end
      if Spud::Blog.config.cache_mode == :full_page
        if record.post.is_news
          expire_page news_post_path(record.post.url_name)
        else
          expire_page blog_post_path(record.post.url_name)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
tb_blog-1.0.4 app/models/spud_post_comment_sweeper.rb
tb_blog-1.0.3 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.11 app/models/spud_post_comment_sweeper.rb
tb_blog-1.0.2 app/models/spud_post_comment_sweeper.rb
tb_blog-1.0.1 app/models/spud_post_comment_sweeper.rb
tb_blog-1.0 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.10 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.9 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.8 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.7 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.5 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.4 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.3 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.2 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.1 app/models/spud_post_comment_sweeper.rb
spud_blog-0.9.0 app/models/spud_post_comment_sweeper.rb