Sha256: 314862d930fc84d2dc6a7f3caf5ada89fb5a8d6662fa263afbadc3641082ff5e

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

class PageSweeper < ActionController::Caching::Sweeper
  include ExpireEditableFragment
  observe Create, Realize, Produce, Own, Exemplify, Patron,
    SeriesStatement, SeriesHasManifestation, PictureFile

  def after_save(record)
    case record.class.to_s.to_sym
    when :Create
      expire_editable_fragment(record.patron)
      expire_editable_fragment(record.work)
    when :Realize
      expire_editable_fragment(record.patron)
      expire_editable_fragment(record.expression)
    when :Produce
      expire_editable_fragment(record.patron)
      expire_editable_fragment(record.manifestation)
    when :Own
      expire_editable_fragment(record.patron)
      expire_editable_fragment(record.item)
      expire_editable_fragment(record.item.manifestation)
    when :Exemplify
      expire_editable_fragment(record.manifestation)
      expire_editable_fragment(record.item)
    when :SeriesStatement
      record.manifestations.each do |manifestation|
        expire_editable_fragment(manifestation)
      end
    when :SeriesHasManifestation
      expire_editable_fragment(record.manifestation)
    when :PictureFile
      if record.picture_attachable_type?
        expire_editable_fragment(record.picture_attachable)
      end
    end
  end

  def after_destroy(record)
    after_save(record)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_biblio-0.0.3 app/models/page_sweeper.rb
enju_biblio-0.0.2 app/models/page_sweeper.rb
enju_biblio-0.0.1 app/models/page_sweeper.rb