Class: Token

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/token.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Constant Summary collapse

@@validity_time =
1.day

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destroy_expiredObject

Delete all expired tokens


33
34
35
# File 'app/models/token.rb', line 33

def self.destroy_expired
  Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
end

Instance Method Details

#before_createObject


23
24
25
# File 'app/models/token.rb', line 23

def before_create
  self.value = Token.generate_token_value
end

#expired?Boolean

Return true if token has expired

Returns:

  • (Boolean)

28
29
30
# File 'app/models/token.rb', line 28

def expired?
  return Time.now > self.created_on + @@validity_time
end