Sha256: 4d442aa707aa2badd93ed9bb4d28ff53335303a60920b9494ba99c29b360c47a
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
# = expirable.rb # # == Copyright (c) 2004 George Moschovitis # # Ruby License # # This module is free software. You may use, modify, and/or redistribute this # software under the same terms as Ruby. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. # # == Author/Contributor # # * George Moschovitis # Author:: George Moschovitis # Copyright:: Copyright (c) 2004 George Moschovitis # License:: Ruby License # = Expirable # # Generic expirability 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 # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # TODO =begin #test require 'test/unit' class TC_Expirable < Test::Unit::TestCase def test_01 end end =end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.20 | lib/facets/more/expirable.rb |
facets-1.8.49 | lib/facets/more/expirable.rb |
facets-1.8.51 | lib/facets/more/expirable.rb |
facets-1.8.54 | lib/facets/more/expirable.rb |