Module: Arcadex::Destroy
- Defined in:
- lib/arcadex/destroy.rb
Class Method Summary collapse
-
.destroy_all_tokens(id, type) ⇒ Object
Arcadex.destroy_all_tokens(instance.id,instance.class.to_s).
-
.destroy_auth_token(auth_token) ⇒ Object
Arcadex.destroy_token(token.auth_token).
- .destroy_token(token) ⇒ Object
-
.token_expired?(token) ⇒ Boolean
Arcadex.token_expired?(token) How long should tokens last? A day if not rememberable And a month if you are?.
Class Method Details
.destroy_all_tokens(id, type) ⇒ Object
Arcadex.destroy_all_tokens(instance.id,instance.class.to_s)
16 17 18 19 20 21 |
# File 'lib/arcadex/destroy.rb', line 16 def self.destroy_all_tokens(id,type) if ::Object.const_get(type).exists?(id) instance = ::Object.const_get(type).find(id) instance.tokens.destroy_all end end |
.destroy_auth_token(auth_token) ⇒ Object
Arcadex.destroy_token(token.auth_token)
5 6 7 8 |
# File 'lib/arcadex/destroy.rb', line 5 def self.destroy_auth_token(auth_token) token = ::Arcadex::Find.find_token_by_auth_token(auth_token) ::Arcadex::Destroy.destroy_token(token) end |
.destroy_token(token) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/arcadex/destroy.rb', line 9 def self.destroy_token(token) if token.nil? return nil end token.destroy end |
.token_expired?(token) ⇒ Boolean
Arcadex.token_expired?(token) How long should tokens last? A day if not rememberable And a month if you are?
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/arcadex/destroy.rb', line 25 def self.token_expired?(token) if !token.expiration_minutes.nil? date = token.created_at.utc + token.expiration_minutes.minutes if ::Time.now.utc > date return true else return false end else return false end end |