class Smith::Cache
Public Class Methods
new()
click to toggle source
# File lib/smith/cache.rb, line 6 def initialize @cache = {} end
Public Instance Methods
delete(name)
click to toggle source
# File lib/smith/cache.rb, line 48 def delete(name) @cache.delete(name) end
each() { |v| ... }
click to toggle source
# File lib/smith/cache.rb, line 36 def each @cache.each_value { |v| yield v } end
empty?()
click to toggle source
# File lib/smith/cache.rb, line 40 def empty? @cache.empty? end
entries()
click to toggle source
# File lib/smith/cache.rb, line 28 def entries @cache.keys.map(&:to_s) end
entry(name, options=nil)
click to toggle source
# File lib/smith/cache.rb, line 14 def entry(name, options=nil) if @cache[name] @cache[name] else if @operator.respond_to?(:call) @cache[name] = @operator.call(name, options) else nil end end end
Also aliased as: []
exist?(name)
click to toggle source
# File lib/smith/cache.rb, line 44 def exist?(name) !@cache[name].nil? end
invalidate(name)
click to toggle source
# File lib/smith/cache.rb, line 32 def invalidate(name) @cache.delete(name) end
operator(operator)
click to toggle source
# File lib/smith/cache.rb, line 10 def operator(operator) @operator = operator end
size()
click to toggle source
# File lib/smith/cache.rb, line 52 def size @cache.size end
to_s()
click to toggle source
# File lib/smith/cache.rb, line 56 def to_s @cache.to_s end
update(name, entry)
click to toggle source
# File lib/smith/cache.rb, line 60 def update(name, entry) @cache[name] = entry end