anyone-oslo/pages

View on GitHub
app/models/concerns/pages_core/sweepable.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module PagesCore
  module Sweepable
    extend ActiveSupport::Concern

    included do
      after_save :sweep_cache!
      after_destroy :sweep_cache!
    end

    attr_accessor :cache_swept

    protected

    def sweep_cache!
      return if cache_swept

      PagesCore::StaticCache.handler.sweep!
      self.cache_swept = true
    end
  end
end