Sha256: 8b49fc7eb8380e345f476095eca0ad68ba9ed76b27670a8c24c960408a783d42

Contents?: true

Size: 779 Bytes

Versions: 21

Compression:

Stored size: 779 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.enable_action_caching
        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.enable_full_page_caching
        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

21 entries across 21 versions & 1 rubygems

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