Class: Alchemy::CacheDigests::TemplateTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/alchemy/cache_digests/template_tracker.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, template) ⇒ TemplateTracker

Returns a new instance of TemplateTracker.



8
9
10
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 8

def initialize(name, template)
  @name, @template = name, template
end

Class Method Details

.call(name, template) ⇒ Object



4
5
6
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 4

def self.call(name, template)
  new(name, template).dependencies
end

Instance Method Details

#dependenciesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 12

def dependencies
  case @name.to_s
  when /^alchemy\/pages\/show/
    return PageLayout.all.collect { |p| "alchemy/page_layouts/_#{p['name']}" }
  when /^alchemy\/page_layouts\/_(.+)/
    page_layout = page_layout($1)
    return element_templates(page_layout) +
           page_layout.fetch('cells', []).map { |name| "alchemy/cells/_#{name}" }
  when /^alchemy\/cells\/_(.+)/
    return element_templates cell_definition($1)
  when /alchemy\/elements\/_(.+)_view/
    essences = essence_types($1)
    element = element_definition($1)
    if element && element['picture_gallery']
      essences += ['EssencePicture']
    end
    return essences.map { |name| "alchemy/essences/_#{name.underscore}_view" }.uniq
  else
    ActionView::DependencyTracker::ERBTracker.call(@name, @template)
  end
end