Module: OAuth2::Provider::Models::TokenExpiry

Extended by:
ActiveSupport::Concern
Defined in:
lib/oauth2/provider/models.rb

Instance Method Summary collapse

Instance Method Details

#expired?Boolean


29
30
31
# File 'lib/oauth2/provider/models.rb', line 29

def expired?
  self.expires_at && self.expires_at < Time.now
end

#expires_inObject


33
34
35
36
37
38
39
# File 'lib/oauth2/provider/models.rb', line 33

def expires_in
  if expired?
    0
  else
    self.expires_at && self.expires_at.to_i - Time.now.to_i
  end
end

#fresh?Boolean


25
26
27
# File 'lib/oauth2/provider/models.rb', line 25

def fresh?
  !expired?
end

#initialize(attributes = {}, *args, &block) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/oauth2/provider/models.rb', line 17

def initialize(attributes = {}, *args, &block)
  attributes ||= {}
  if default_token_lifespan
    attributes = attributes.reverse_merge(:expires_at => default_token_lifespan.from_now)
  end
  super
end