Sha256: 5a3546047229570ca7108571e9f195dec20422ce0f0c42a6f57d68dd07088b4b

Contents?: true

Size: 479 Bytes

Versions: 14

Compression:

Stored size: 479 Bytes

Contents

module Alchemy
  class PicturesSweeper < ActionController::Caching::Sweeper
    observe Alchemy::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.join('public', Alchemy::MountPoint.get, 'pictures', picture.id.to_s))
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.9.0 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.8.3 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.5 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.6.3 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.4 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.8.2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.8.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.3 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.7.0 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.6.2.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.6.2 app/sweepers/alchemy/pictures_sweeper.rb