Class: Ki::HashCache
Overview
Caching Hash, resolves values at request time
Instance Method Summary collapse
-
#cache(key, &block) ⇒ Object
If key has not been defined, uses block to resolve the value.
Methods inherited from Hash
Instance Method Details
#cache(key, &block) ⇒ Object
If key has not been defined, uses block to resolve the value. Value is stored and returned
24 25 26 27 28 29 |
# File 'lib/util/hash_cache.rb', line 24 def cache(key, &block) if !include?(key) store(key, block.call) end self[key] end |