Class: Ace::Git::Secrets::Models::RevocationResult
- Inherits:
-
Object
- Object
- Ace::Git::Secrets::Models::RevocationResult
- Defined in:
- lib/ace/git/secrets/models/revocation_result.rb
Overview
Represents the result of a token revocation attempt Immutable value object containing revocation outcome
Constant Summary collapse
- STATUSES =
Valid revocation statuses
%w[revoked failed unsupported skipped].freeze
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#revoked_at ⇒ Object
readonly
Returns the value of attribute revoked_at.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.failure(token:, service:, message:) ⇒ RevocationResult
Create a failed revocation result.
-
.success(token:, service:, message: nil) ⇒ RevocationResult
Create a successful revocation result.
-
.unsupported(token:, service: nil) ⇒ RevocationResult
Create an unsupported revocation result.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Check if revocation failed.
-
#initialize(token:, service:, status:, message: nil, revoked_at: nil) ⇒ RevocationResult
constructor
A new instance of RevocationResult.
-
#skipped? ⇒ Boolean
Check if revocation was skipped.
-
#success? ⇒ Boolean
Check if revocation was successful.
-
#to_h ⇒ Hash
Convert to hash for serialization.
-
#unsupported? ⇒ Boolean
Check if token type is unsupported for revocation.
Constructor Details
#initialize(token:, service:, status:, message: nil, revoked_at: nil) ⇒ RevocationResult
Returns a new instance of RevocationResult.
20 21 22 23 24 25 26 27 28 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 20 def initialize(token:, service:, status:, message: nil, revoked_at: nil) @token = token @service = service @status = validate_status(status) @message = @revoked_at = revoked_at || ((status == "revoked") ? Time.now : nil) freeze end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 10 def @message end |
#revoked_at ⇒ Object (readonly)
Returns the value of attribute revoked_at.
10 11 12 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 10 def revoked_at @revoked_at end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
10 11 12 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 10 def service @service end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 10 def status @status end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
10 11 12 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 10 def token @token end |
Class Method Details
.failure(token:, service:, message:) ⇒ RevocationResult
Create a failed revocation result
86 87 88 89 90 91 92 93 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 86 def self.failure(token:, service:, message:) new( token: token, service: service, status: "failed", message: ) end |
.success(token:, service:, message: nil) ⇒ RevocationResult
Create a successful revocation result
72 73 74 75 76 77 78 79 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 72 def self.success(token:, service:, message: nil) new( token: token, service: service, status: "revoked", message: || "Token successfully revoked" ) end |
.unsupported(token:, service: nil) ⇒ RevocationResult
Create an unsupported revocation result
99 100 101 102 103 104 105 106 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 99 def self.unsupported(token:, service: nil) new( token: token, service: service || "unknown", status: "unsupported", message: "Token type #{token.token_type} does not support automatic revocation" ) end |
Instance Method Details
#failed? ⇒ Boolean
Check if revocation failed
38 39 40 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 38 def failed? status == "failed" end |
#skipped? ⇒ Boolean
Check if revocation was skipped
50 51 52 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 50 def skipped? status == "skipped" end |
#success? ⇒ Boolean
Check if revocation was successful
32 33 34 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 32 def success? status == "revoked" end |
#to_h ⇒ Hash
Convert to hash for serialization
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 56 def to_h { token_type: token.token_type, masked_value: token.masked_value, service: service, status: status, message: , revoked_at: revoked_at&.iso8601 } end |
#unsupported? ⇒ Boolean
Check if token type is unsupported for revocation
44 45 46 |
# File 'lib/ace/git/secrets/models/revocation_result.rb', line 44 def unsupported? status == "unsupported" end |