Class: Redd::Models::Access
- Inherits:
-
BasicModel
- Object
- BasicModel
- Redd::Models::Access
- Defined in:
- lib/redd/models/access.rb
Overview
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.
Models access_token and related keys.
Instance Attribute Summary
Attributes inherited from BasicModel
Instance Method Summary collapse
- #expired?(grace_period = 60) ⇒ Boolean
-
#initialize(client = nil, attributes = {}) ⇒ Access
constructor
Create a non-lazily initialized Access.
- #permanent? ⇒ Boolean
Methods inherited from BasicModel
from_id, #inspect, #method_missing, #respond_to_missing?, #to_ary, #to_h
Constructor Details
#initialize(client = nil, attributes = {}) ⇒ Access
Create a non-lazily initialized Access.
17 18 19 20 21 22 23 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Redd::Models::BasicModel
Instance Method Details
#expired?(grace_period = 60) ⇒ Boolean
25 26 27 28 29 |
# 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? ⇒ Boolean
31 32 33 |
# File 'lib/redd/models/access.rb', line 31 def permanent? !@attributes[:refresh_token].nil? end |