Class: Tilt::Cache
- Inherits:
-
Object
- Object
- Tilt::Cache
- Defined in:
- lib/sinatra/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, ) { Tilt.new(path, line, ) }
Subsequent invocations return the already compiled template object.
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(*key) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
178 179 180 |
# File 'lib/sinatra/tilt.rb', line 178 def initialize @cache = {} end |
Instance Method Details
#clear ⇒ Object
186 187 188 |
# File 'lib/sinatra/tilt.rb', line 186 def clear @cache = {} end |
#fetch(*key) ⇒ Object
182 183 184 |
# File 'lib/sinatra/tilt.rb', line 182 def fetch(*key) @cache[key] ||= yield end |