Sha256: e53ccf972f8623e9f38b5f0972dbb852035a51690c5f2b90d2e4e3e5d1f75623

Contents?: true

Size: 1.31 KB

Versions: 59

Compression:

Stored size: 1.31 KB

Contents

class PageSweeper < ActionController::Caching::Sweeper
  include ExpireEditableFragment
  observe SubjectHeadingType, Tag,
    Subject, Classification, SubjectHeadingTypeHasSubject,
    WorkHasSubject

  def after_save(record)
    case
    when record.is_a?(Tag)
      record.taggings.collect(&:taggable).each do |taggable|
        expire_editable_fragment(taggable)
      end
    when record.is_a?(Subject)
      expire_editable_fragment(record)
      record.works.each do |work|
        expire_editable_fragment(work)
      end
      record.classifications.each do |classification|
        expire_editable_fragment(classification)
      end
    when record.is_a?(Classification)
      expire_editable_fragment(record)
      record.subjects.each do |subject|
        expire_editable_fragment(subject)
      end
    when record.is_a?(SubjectHeadingTypeHasSubject)
      expire_editable_fragment(record.subject)
    when record.is_a?(WorkHasSubject)
      expire_editable_fragment(record.work)
      expire_editable_fragment(record.subject)
    end
  end

  def after_destroy(record)
    after_save(record)
  end

  def expire_menu
    I18n.available_locales.each do |locale|
      Role.all_cache.each do |role|
        expire_fragment(:controller => :page, :page => 'menu', :role => role.name, :locale => locale)
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
enju_subject-0.2.3 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.2 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.1 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0.beta.5 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0.beta.4 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0.beta.3 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0.beta.2 lib/enju_subject/page_sweeper.rb
enju_subject-0.2.0.beta.1 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.1 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre34 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre33 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre32 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre31 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre30 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre29 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre28 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre27 lib/enju_subject/page_sweeper.rb
enju_subject-0.1.0.pre26 lib/enju_subject/page_sweeper.rb