Sha256: f40b30aa78e6b43f32a9d957c75c2b42c66bf6fd865fa84975a74ae6cb418c92
Contents?: true
Size: 637 Bytes
Versions: 9
Compression:
Stored size: 637 Bytes
Contents
# * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. # $Id$ module N # 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
9 entries across 9 versions & 3 rubygems