Sha256: 66a6131885fcb84ee1a059ef744476893e567fd1d18ab59437a7b395852e84b0
Contents?: true
Size: 711 Bytes
Versions: 5
Compression:
Stored size: 711 Bytes
Contents
# * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. # $Id: mixins.rb 182 2005-07-22 10:07:50Z gmosx $ module Glue # Generic expiring functionality mixin. module Expirable attr_accessor :expires # Set the expires timeout for this entry. def expires_after(timeout = (60*60*24)) @expires = Time.now + timeout end # Set the expire timeout for this entry. The timeout happens # after (base + rand(spread)) seconds. def expires_spread(base, spread) @expires = Time.now + base + rand(spread) end # Is this entry expired? def expired? if @expires.nil? or (Time.now > @expires) return true else return false end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
glue-0.22.0 | lib/glue/mixins.rb |
glue-0.21.0 | lib/glue/mixins.rb |
glue-0.21.2 | lib/glue/mixins.rb |
glue-0.23.0 | lib/glue/mixins.rb |
glue-0.24.0 | lib/glue/mixins.rb |