Sha256: d736eb9af580f6b2b3ba1cfb73d67910d0eeb2fede5695d7284ca20a81a4b1a3
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
class SpudBannerSweeper < ActionController::Caching::Sweeper observe :spud_banner, :spud_banner_set def before_save(record) if record.is_a?(SpudBannerSet) @old_name = record.name end end def after_save(record) expire_cache_for(record) end def after_destroy(record) expire_cache_for(record) end private def expire_cache_for(record) # lazy full page cache clear cache_path = ActionController::Base.page_cache_directory if cache_path != Rails.root && cache_path != Rails.public_path && File.directory?(cache_path) FileUtils.rm_rf(cache_path) end # reprocess cached liquid tags if defined?(Spud::Cms) values = [record.set_name] values << @old_name if !@old_name.blank? SpudPageLiquidTag.where(:tag_name => "banner_set",:value => values).includes(:attachment).each do |tag| partial = tag.attachment partial.postprocess_content partial.save page = partial.try(:spud_page) if page.blank? == false page.updated_at = Time.now.utc page.save end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spud_banners-0.9.1 | app/observers/spud_banner_sweeper.rb |