Class: Spree::BaseHelperDecorator::ChildTaxonsSection

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/helpers/spree/base_helper_decorator.rb

Overview

永続化されていない PageSection をラップし、フラグメントキャッシュのキーを 子カテゴリの内容から導出する。 未保存の AR レコードは cache_key が常に ".../new" になり、カテゴリを跨いで キャッシュが衝突するため。

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



33
34
35
36
37
# File 'app/helpers/spree/base_helper_decorator.rb', line 33

def cache_key
  child_taxon_ids = links.map(&:linkable_id)
  max_updated_at = links.filter_map(&:linkable).map(&:updated_at).max.to_i
  "spree/page_sections/child_taxons/#{child_taxon_ids.join('-')}-#{max_updated_at}"
end

#cache_key_with_versionObject

ActiveSupport::Cache は cache_key より先にこちらを見るため、 委譲先の実装が使われないよう合わせて上書きする



41
42
43
# File 'app/helpers/spree/base_helper_decorator.rb', line 41

def cache_key_with_version
  cache_key
end