class Startling::Cache
Attributes
cache_dir[R]
Public Class Methods
new(cache_dir)
click to toggle source
# File lib/startling/cache.rb, line 5 def initialize(cache_dir) @cache_dir = cache_dir end
Public Instance Methods
fetch(path, &block)
click to toggle source
# File lib/startling/cache.rb, line 9 def fetch(path, &block) path = File.join(cache_dir, path) if File.exists? path File.read path else block.call.tap do |value| File.write path, value end end end