Class: Tilt::Cache

Inherits:
Object show all
Defined in:
lib/vendor/tilt-1.4.1/lib/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.



122
123
124
# File 'lib/vendor/tilt-1.4.1/lib/tilt.rb', line 122

def initialize
  @cache = {}
end

Instance Method Details

#clearObject



130
131
132
# File 'lib/vendor/tilt-1.4.1/lib/tilt.rb', line 130

def clear
  @cache = {}
end

#fetch(*key) ⇒ Object



126
127
128
# File 'lib/vendor/tilt-1.4.1/lib/tilt.rb', line 126

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