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.



10
11
12
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 10

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

Class Method Details

.call(name, template) ⇒ Object



6
7
8
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 6

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

Instance Method Details

#dependenciesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/alchemy/cache_digests/template_tracker.rb', line 14

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