Sha256: 21014f7a63c22f0ebc641f4e091200519a2d43a818b0e89472453e2c7cfc47e2

Contents?: true

Size: 1003 Bytes

Versions: 10

Compression:

Stored size: 1003 Bytes

Contents

class TaggableSweeper < ActionController::Caching::Sweeper
  observe User, Post, Clipping, Photo # This sweeper is going to keep an eye on taggable models

  # If our sweeper detects that a taggable (User) was activated 
  def after_activate(taggable)
    expire_cache_for(taggable)
  end

  # If our sweeper detects that a taggable was created
  def after_create(taggable)
    expire_cache_for(taggable)
  end

  # If our sweeper detects that a photo was uploaded
  def after_swfupload(photo)
    expire_cache_for(taggable)    
  end
  
  # If our sweeper detects that a taggable was updated 
  def after_update(taggable)
    expire_cache_for(taggable)
  end
  
  # If our sweeper detects that a taggable was deleted
  def after_destroy(taggable)
    expire_cache_for(taggable)
  end
          
  private
  def expire_cache_for(record)
    # Expire the tag show pages
    record.tags.each do |tag|
      expire_action({:action=>"show", :controller=>"tags", :id => tag.id})      
    end
  end
  
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
community_engine-3.2.0 app/controllers/taggable_sweeper.rb
community_engine-3.0.0 app/controllers/taggable_sweeper.rb
community_engine-2.3.2 app/controllers/taggable_sweeper.rb
community_engine-2.3.1 app/controllers/taggable_sweeper.rb
community_engine-2.3.0 app/controllers/taggable_sweeper.rb
community_engine-2.1.0 app/controllers/taggable_sweeper.rb
community_engine-2.0.0 app/controllers/taggable_sweeper.rb
community_engine-2.0.0.beta3 app/controllers/taggable_sweeper.rb
community_engine-2.0.0.beta2 app/controllers/taggable_sweeper.rb
community_engine-2.0.0.beta1 app/controllers/taggable_sweeper.rb