Class: ExpireFragmentCache

Inherits:
Object
  • Object
show all
Defined in:
lib/enju_core/expire_fragment_cache.rb

Class Method Summary collapse

Class Method Details

.expire_fragment_cache(record, fragments = []) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/enju_core/expire_fragment_cache.rb', line 2

def self.expire_fragment_cache(record, fragments = [])
  if record.is_a?(Manifestation)
    if fragments.empty?
      fragments = %w[manifestation_html show_detail_user_html show_detail_librarian_html pickup_html title_html title_mobile index_sru]
    end
  end

  I18n.available_locales.each do |locale|
    Role.all_cache.each do |role|
      fragments.each do |fragment|
        Rails.cache.clear([":#{record.class.to_s.downcase}" => record.id, :fragment => fragment, :role => role.name, :locale => locale])
      end
    end
  end
end