Module: Cacheable::ModelFetch
- Included in:
- Cacheable
- Defined in:
- lib/cacheable/model_fetch.rb
Instance Method Summary collapse
Instance Method Details
#fetch(key, options = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/cacheable/model_fetch.rb', line 3 def fetch(key, =nil) unless result = read(key, ) if block_given? result = yield write(key, result, ) unless result.nil? end end result end |