Class: NebulaToken::RefreshResult
- Inherits:
-
Object
- Object
- NebulaToken::RefreshResult
- Defined in:
- lib/nebula_token.rb
Overview
Result of Engine#refresh ([N-29]: outcomes are values, never exceptions).
user_id and family_id are populated whenever the engine resolved a
record — every code except MALFORMED, UNKNOWN_KID and NOT_FOUND — so a
REUSE_DETECTED or DEVICE_MISMATCH event can be attributed to a session
without a second lookup of a token you were told never to log ([N-39]).
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#family_id ⇒ Object
readonly
Returns the value of attribute family_id.
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
-
#idle_expires_at ⇒ Object
readonly
Returns the value of attribute idle_expires_at.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
-
.failure(error, record = nil) ⇒ Object
recordis nil exactly when nothing was resolved ([N-39]). - .success(token:, user_id:, family_id:, generation:, expires_at:, idle_expires_at:) ⇒ Object
Instance Method Summary collapse
-
#initialize(ok:, token: nil, user_id: nil, family_id: nil, generation: nil, expires_at: nil, idle_expires_at: nil, error: nil) ⇒ RefreshResult
constructor
rubocop:disable Metrics/ParameterLists.
-
#inspect ⇒ Object
(also: #to_s)
[N-14], as for IssueResult.
-
#ok? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(ok:, token: nil, user_id: nil, family_id: nil, generation: nil, expires_at: nil, idle_expires_at: nil, error: nil) ⇒ RefreshResult
rubocop:disable Metrics/ParameterLists
528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/nebula_token.rb', line 528 def initialize(ok:, token: nil, user_id: nil, family_id: nil, generation: nil, expires_at: nil, idle_expires_at: nil, error: nil) @ok = ok @token = token @user_id = user_id @family_id = family_id @generation = generation @expires_at = expires_at @idle_expires_at = idle_expires_at @error = error freeze end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def error @error end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def expires_at @expires_at end |
#family_id ⇒ Object (readonly)
Returns the value of attribute family_id.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def family_id @family_id end |
#generation ⇒ Object (readonly)
Returns the value of attribute generation.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def generation @generation end |
#idle_expires_at ⇒ Object (readonly)
Returns the value of attribute idle_expires_at.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def idle_expires_at @idle_expires_at end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def token @token end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
525 526 527 |
# File 'lib/nebula_token.rb', line 525 def user_id @user_id end |
Class Method Details
.failure(error, record = nil) ⇒ Object
record is nil exactly when nothing was resolved ([N-39]).
550 551 552 |
# File 'lib/nebula_token.rb', line 550 def self.failure(error, record = nil) new(ok: false, error: error, user_id: record&.user_id, family_id: record&.family_id) end |
.success(token:, user_id:, family_id:, generation:, expires_at:, idle_expires_at:) ⇒ Object
544 545 546 547 |
# File 'lib/nebula_token.rb', line 544 def self.success(token:, user_id:, family_id:, generation:, expires_at:, idle_expires_at:) new(ok: true, token: token, user_id: user_id, family_id: family_id, generation: generation, expires_at: expires_at, idle_expires_at: idle_expires_at) end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
[N-14], as for IssueResult.
555 556 557 558 559 |
# File 'lib/nebula_token.rb', line 555 def inspect "#<NebulaToken::RefreshResult ok=#{@ok} error=#{@error.inspect} " \ "user_id=#{@user_id.inspect} family_id=#{@family_id.inspect} " \ "generation=#{@generation.inspect} token=#{@token.nil? ? 'nil' : '[REDACTED]'}>" end |
#ok? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
542 |
# File 'lib/nebula_token.rb', line 542 def ok? = @ok |