Module: Doorkeeper::Models::Expirable

Included in:
AccessGrantMixin, AccessTokenMixin
Defined in:
lib/doorkeeper/models/concerns/expirable.rb

Instance Method Summary collapse

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/doorkeeper/models/concerns/expirable.rb', line 4

def expired?
  expires_in && Time.now > expired_time
end

#expires_in_secondsObject


8
9
10
11
12
13
# File 'lib/doorkeeper/models/concerns/expirable.rb', line 8

def expires_in_seconds
  return nil if expires_in.nil?
  expires = (created_at + expires_in.seconds) - Time.now
  expires_sec = expires.seconds.round(0)
  expires_sec > 0 ? expires_sec : 0
end