Sha256: 01a1466d3898e23b4f52605b812454a6641d7a8757a173ce4c9e6b91a2c65a5a

Contents?: true

Size: 475 Bytes

Versions: 40

Compression:

Stored size: 475 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.mount_point, 'pictures', picture.id.to_s))
    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
alchemy_cms-2.6.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.6.0 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.6.0.rc5 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.3.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.3 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.2.2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.2.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.0 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.0.rc3 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.0.b9 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.3.2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.2.4 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.4.1 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.0.b5 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.5.0.b2 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.4.0 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.4.rc4 app/sweepers/alchemy/pictures_sweeper.rb
alchemy_cms-2.4.rc2 app/sweepers/alchemy/pictures_sweeper.rb