aboutsummaryrefslogtreecommitdiffstats
path: root/app/sweepers/refinery/blog_sweeper.rb
blob: ceed5fa4e44681c67dd35af62473030f59f8b65b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Refinery
  class BlogSweeper < ActionController::Caching::Sweeper
    observe BlogPost, BlogComment
    
    def after_create(record)
      expire_cache_for(record)
    end
    
    def after_update(record)
      expire_cache_for(record)
    end
    
    def after_destroy(record)
      expire_cache_for(record)
    end
    
    private
    
      def expire_cache_for(record)
        # TODO: Convert these to url helpers
        expire_page '/blog'
        expire_page '/blog/feed.rss'
      end
      
  end
end