Class: CASinoCore::Model::ProxyTicket

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/casino_core/model/proxy_ticket.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cleanup_consumedObject



15
16
17
# File 'lib/casino_core/model/proxy_ticket.rb', line 15

def self.cleanup_consumed
  self.destroy_all(['created_at < ? AND consumed = ?', CASinoCore::Settings.proxy_ticket[:lifetime_consumed].seconds.ago, true])
end

.cleanup_unconsumedObject



11
12
13
# File 'lib/casino_core/model/proxy_ticket.rb', line 11

def self.cleanup_unconsumed
  self.destroy_all(['created_at < ? AND consumed = ?', CASinoCore::Settings.proxy_ticket[:lifetime_unconsumed].seconds.ago, false])
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
# File 'lib/casino_core/model/proxy_ticket.rb', line 19

def expired?
  lifetime = if consumed?
    CASinoCore::Settings.proxy_ticket[:lifetime_consumed]
  else
    CASinoCore::Settings.proxy_ticket[:lifetime_unconsumed]
  end
  (Time.now - (self.created_at || Time.now)) > lifetime
end