Class: VagrantCloud::Auth::HCPToken
- Inherits:
-
Struct
- Object
- Struct
- VagrantCloud::Auth::HCPToken
- Defined in:
- lib/vagrant_cloud/auth.rb
Overview
HCP token
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
seconds prior to actual expiry.
-
#valid? ⇒ Boolean
Token is not expired.
-
#validate! ⇒ Object
Raise exception if any values are missing.
Instance Attribute Details
#expires_at ⇒ Object
Returns the value of attribute expires_at
36 37 38 |
# File 'lib/vagrant_cloud/auth.rb', line 36 def expires_at @expires_at end |
#token ⇒ Object
Returns the value of attribute token
36 37 38 |
# File 'lib/vagrant_cloud/auth.rb', line 36 def token @token end |
Instance Method Details
#expired? ⇒ Boolean
Note:
Will show token as expired TOKEN_EXPIRY_PADDING
seconds prior to actual expiry
48 49 50 51 52 |
# File 'lib/vagrant_cloud/auth.rb', line 48 def expired? validate! Time.now.to_i > (expires_at - TOKEN_EXPIRY_PADDING) end |
#valid? ⇒ Boolean
Returns token is not expired.
55 56 57 |
# File 'lib/vagrant_cloud/auth.rb', line 55 def valid? !expired? end |
#validate! ⇒ Object
Raise exception if any values are missing
38 39 40 41 42 43 |
# File 'lib/vagrant_cloud/auth.rb', line 38 def validate! [:token, :expires_at].each do |name| raise ArgumentError, "Missing required token value - #{name.inspect}" if self.send(name).nil? end end |