Class: Cell::Templates::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/cell/templates.rb

Overview

comment/views“] => ”Tpl:comment/view/show.haml“

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



32
33
34
# File 'lib/cell/templates.rb', line 32

def initialize
  @store = {}
end

Instance Method Details

#fetch(prefixes, view) ⇒ Object

Iterates prefixes and yields block. Returns and caches when block returned template. Note that it caches per prefixes set as this will most probably never change.



38
39
40
41
42
43
44
# File 'lib/cell/templates.rb', line 38

def fetch(prefixes, view)
  template = get(prefixes, view) and return template # cache hit.

  prefixes.find do |prefix|
    template = yield(prefix) and return store(prefixes, view, template)
  end
end