module Lingo::Cachable

Provides a simple caching mechanism.

Public Instance Methods

hit?(key) click to toggle source
# File lib/lingo/cachable.rb, line 36
def hit?(key)
  @cachable_hash.has_key?(key)
end
init_cachable() click to toggle source
# File lib/lingo/cachable.rb, line 32
def init_cachable
  @cachable_hash = Hash.new(false)
end
retrieve(key) click to toggle source
# File lib/lingo/cachable.rb, line 45
def retrieve(key)
  cache_value(@cachable_hash[key])
end
store(key, val) click to toggle source
# File lib/lingo/cachable.rb, line 40
def store(key, val)
  @cachable_hash[key] = cache_value(val)
  val
end

Private Instance Methods

cache_value(val) click to toggle source
# File lib/lingo/cachable.rb, line 51
def cache_value(val)
  val.dup unless val.nil?
end