Class: Alchemy::Page::EtagGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/models/alchemy/page/etag_generator.rb

Overview

Generates an ETag for a page.

By default, it uses the page’s id and the ids of its published elements. You can customize this by providing your own generator in the configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ EtagGenerator

Returns a new instance of EtagGenerator.

Parameters:

  • page (Alchemy::Page)

    The page for which to generate the ETag.



10
11
12
# File 'app/models/alchemy/page/etag_generator.rb', line 10

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



7
8
9
# File 'app/models/alchemy/page/etag_generator.rb', line 7

def page
  @page
end

Instance Method Details

#call(*args) ⇒ Array<Object>

Parameters:

  • args (Array<Object>)

    Additional arguments that can be used in the ETag generation.

Returns:

  • (Array<Object>)


16
17
18
19
# File 'app/models/alchemy/page/etag_generator.rb', line 16

def call(*args)
  elements_cache_key = page.public_version&.elements&.published&.order(:id)&.pluck(:id)
  [page, elements_cache_key, *args]
end