Sha256: ce6d59aacfffd9d4ea938d67d406fa9f18858baea4ee9a045db8bf5f1e654abe

Contents?: true

Size: 532 Bytes

Versions: 14

Compression:

Stored size: 532 Bytes

Contents

class PicturesSweeper < ActionController::Caching::Sweeper
  observe Picture

  def after_update(picture)
    expire_cache_for(picture)
  end

  def after_destroy(picture)
    expire_cache_for(picture)
  end

private

  def expire_cache_for(picture)
    # Removing all variants of the picture with FileUtils.
    FileUtils.rm_rf("#{Rails.root}/public/pictures/show/#{picture.id}")
    FileUtils.rm_rf("#{Rails.root}/public/pictures/thumbnails/#{picture.id}")
    expire_page(zoom_picture_path(picture, :format => 'png'))
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-2.0.7 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.6.1 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.5 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.4 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.3.1 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.1.beta1 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.3 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.2 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.1 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.rc6 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.rc5 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.rc4 app/sweepers/pictures_sweeper.rb
alchemy_cms-2.0.rc3 app/sweepers/pictures_sweeper.rb