Class: Token
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Token
- Defined in:
- lib/a_b/model/token.rb
Constant Summary collapse
- @@cached_at =
nil
Class Method Summary collapse
Class Method Details
.cached ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/a_b/model/token.rb', line 6 def self.cached if @@cached_at.nil? || @@cached_at < Time.now.utc - 60 @@cached = self.last.token @@cached_at = Time.now.utc end @@cached end |
.generate! ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/a_b/model/token.rb', line 14 def self.generate! if !self.last or (self.last.created_at < Time.now.utc - 60 * 60) token = self.create(:token => Authlogic::Random.friendly_token).token else token = self.last.token end token end |