Sha256: 64438907ce908abab24393e86281d162b15bfc4af3e282ecee7c95c280f7a327

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

class SpudPhotoSweeper < ActionController::Caching::Sweeper

  observe :spud_photo, :spud_photo_album, :spud_photo_gallery

  def after_create(record)
    expire_cache_for(record)
  end

  def before_update(record)
    expire_cache_for(record)
  end

  def after_destroy(record)
    expire_cache_for(record)
  end

private

  def expire_cache_for(record)
    if Spud::Photos.config.enable_full_page_caching
      cache_path = File.join(ActionController::Base.page_cache_directory, Spud::Photos.config.base_path)
      if File.directory?(cache_path)
        FileUtils.rm_rf(cache_path)
      end
      if !Spud::Photos.config.page_caches_to_sweep.blank?
        Spud::Photos.config.page_caches_to_sweep.each do |route|
          expire_page(route)
        end
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spud_photos-0.9.0.2 app/models/spud_photo_sweeper.rb
spud_photos-0.9.0.1 app/models/spud_photo_sweeper.rb
spud_photos-0.9.0 app/models/spud_photo_sweeper.rb