Sha256: 9b18a73604b4e4d946fc15a9090c4473df94bd209d298fe7230b8c7b63930e1c
Contents?: true
Size: 708 Bytes
Versions: 4
Compression:
Stored size: 708 Bytes
Contents
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 # Update the expiration period. Override in your application. def touch! end end end # * George Moschovitis <gm@navel.gr>
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
glue-0.28.0 | lib/glue/expirable.rb |
glue-0.26.0 | lib/glue/expirable.rb |
glue-0.27.0 | lib/glue/expirable.rb |
glue-0.29.0 | lib/glue/expirable.rb |