Class: CASino::ProxyTicket

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ModelConcern::Ticket
Defined in:
app/models/casino/proxy_ticket.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cleanup_consumedObject



16
17
18
# File 'app/models/casino/proxy_ticket.rb', line 16

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

.cleanup_unconsumedObject



12
13
14
# File 'app/models/casino/proxy_ticket.rb', line 12

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

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'app/models/casino/proxy_ticket.rb', line 20

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