class Redd::Models::Access
Models
access_token and related keys. @note This model also supports an additional key, called `:created_at` which is a UNIX time
representing the time the access was created. The default value is the time the object was initialized.
Public Class Methods
new(client = nil, attributes = {})
click to toggle source
Create a non-lazily initialized Access
. @param client [Object] (deprecated) the client to create the object with @param attributes [Hash] the Access's attributes @example
access = Redd::Models::Access.new(access_token: ...)
Calls superclass method
# File lib/redd/models/access.rb, line 17 def initialize(client = nil, attributes = {}) if client.is_a?(Hash) super(nil, client) else super(client, attributes) end end
Public Instance Methods
expired?(grace_period = 60)
click to toggle source
# File lib/redd/models/access.rb, line 25 def expired?(grace_period = 60) # We're not sure, so we just assume it hasn't expired. return false unless @attributes[:expires_in] Time.now.to_i > @attributes[:created_at] + (@attributes[:expires_in] - grace_period) end
permanent?()
click to toggle source
# File lib/redd/models/access.rb, line 31 def permanent? !@attributes[:refresh_token].nil? end
Private Instance Methods
after_initialize()
click to toggle source
# File lib/redd/models/access.rb, line 37 def after_initialize @attributes[:created_at] ||= Time.now.to_i end