Permalink
Browse files

Add sweepers

  • Loading branch information...
1 parent 4e6d191 commit e966c7d22ea35d6aaf03bd655b6ec5eaa1ca8260 @radar radar committed Apr 2, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 app/sweepers/tickets_sweeper.rb
@@ -0,0 +1,20 @@
+class TicketsSweeper < ActionController::Caching::Sweeper
+ observe Ticket
+ def after_create(ticket)
+ expire_fragments_for_project(ticket.project)
+ end
+
+ def after_update(ticket)
+ expire_fragments_for_project(ticket.project)
+ end
+
+ def after_destroy(ticket)
+ expire_fragments_for_project(ticket.project)
+ end
+
+ private
+
+ def expire_fragments_for_project(project)
+ expire_fragment(/projects\/#{project.id}\/.*?/)
+ end
+end

0 comments on commit e966c7d

Please sign in to comment.