Method: Bunch::Cache.fetch
- Defined in:
- lib/bunch/cache.rb
.fetch(fn, &blk) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bunch/cache.rb', line 26 def fetch(fn, &blk) current_mtime = File.mtime(fn) if stored?(fn) && mtime(fn) == current_mtime read(fn) else content = blk.call write(fn, current_mtime, content) content end end |