lib/mixers/expirable.rb in mixers-1.1.0 vs lib/mixers/expirable.rb in mixers-1.2.0

- old
+ new

@@ -2,45 +2,36 @@ # # Generic expirability mixin. # module Expirable - attr_accessor :expiration + attr_reader :expiration # Set the expires timeout for this entry. - def expiration=(time) case time when Time, Date, DateTime @expiration = time else @expiration = Time.now + time end end - #def expires_after(timeout = 86400) - # @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 + ## + ##def expires_spread(base, spread) + ## @expires = Time.now + base + rand(spread) + ##end # Is this entry expired? - def expired? - if @expiration.nil? or (Time.now > @expiration) - return true - else - return false - end + return true if expiration.nil? + return true if (Time.now > expiration) + return false end # Update the expiration period. Override in your application. - def touch! end end