2012-08-09 16:34:56 -07:00
|
|
|
class ItemObserver < ActionController::Caching::Sweeper
|
2012-12-29 22:46:36 -08:00
|
|
|
include FragmentExpiration
|
|
|
|
|
2012-08-09 19:35:30 -07:00
|
|
|
def after_create(item)
|
2013-12-08 22:12:05 -08:00
|
|
|
Resque.enqueue(Item::CreateTask, item.id)
|
2012-08-09 19:35:30 -07:00
|
|
|
end
|
|
|
|
|
2012-08-09 16:34:56 -07:00
|
|
|
def after_update(item)
|
2013-12-08 22:12:05 -08:00
|
|
|
# CONSIDER: can pass item.changes.keys in to choose which caches to expire
|
|
|
|
Resque.enqueue(Item::UpdateTask, item.id)
|
2012-08-09 16:34:56 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_destroy(item)
|
2013-12-08 22:12:05 -08:00
|
|
|
Resque.enqueue(Item::DestroyTask, item.id)
|
2012-08-09 16:34:56 -07:00
|
|
|
end
|
|
|
|
end
|