class Ki::HashCache

Caching Hash, resolves values at request time

Public Instance Methods

cache(key, &block) click to toggle source

If key has not been defined, uses block to resolve the value. Value is stored and returned @param key Key @param [Proc] block Block which is evaluated if the key does not have value yet. Block's value is stored to hash @return Existing value or one resolved with the block

# File lib/util/hash_cache.rb, line 24
def cache(key, &block)
  if !include?(key)
    store(key, block.call)
  end
  self[key]
end