Class: Yt::Models::Authentication
- Inherits:
-
Object
- Object
- Yt::Models::Authentication
- Defined in:
- lib/yt/models/authentication.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #expire ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(data = {}) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(data = {}) ⇒ Authentication
Returns a new instance of Authentication.
6 7 8 9 10 |
# File 'lib/yt/models/authentication.rb', line 6 def initialize(data = {}) @access_token = data['access_token'] @refresh_token = data['refresh_token'] @expires_at = expiration_date data.slice('expires_at', 'expires_in') end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
4 5 6 |
# File 'lib/yt/models/authentication.rb', line 4 def access_token @access_token end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
4 5 6 |
# File 'lib/yt/models/authentication.rb', line 4 def expires_at @expires_at end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
4 5 6 |
# File 'lib/yt/models/authentication.rb', line 4 def refresh_token @refresh_token end |
Instance Method Details
#expire ⇒ Object
16 17 18 |
# File 'lib/yt/models/authentication.rb', line 16 def expire @expires_at = 10.years.ago end |
#expired? ⇒ Boolean
12 13 14 |
# File 'lib/yt/models/authentication.rb', line 12 def expired? @expires_at && @expires_at.past? end |