Class: Tilt::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/frank/tilt.rb

Overview

Extremely simple template cache implementation. Calling applications create a Tilt::Cache instance and use #fetch with any set of hashable arguments (such as those to Tilt.new):

cache = Tilt::Cache.new
cache.fetch(path, line, options) { Tilt.new(path, line, options) }

Subsequent invocations return the already loaded template object.

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



324
325
326
# File 'lib/frank/tilt.rb', line 324

def initialize
  @cache = {}
end

Instance Method Details

#clearObject



332
333
334
# File 'lib/frank/tilt.rb', line 332

def clear
  @cache = {}
end

#fetch(*key) ⇒ Object



328
329
330
# File 'lib/frank/tilt.rb', line 328

def fetch(*key)
  @cache[key] ||= yield
end