Class: IdempotencyLock::Result
- Inherits:
-
Object
- Object
- IdempotencyLock::Result
- Defined in:
- lib/idempotency_lock/result.rb
Overview
Represents the result of an idempotency operation.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#error? ⇒ Boolean
True if an error occurred during execution.
-
#executed? ⇒ Boolean
True if the block was executed.
-
#initialize(executed:, value: nil, skipped: false, error: nil) ⇒ Result
constructor
A new instance of Result.
-
#inspect ⇒ String
Human-readable representation for debugging.
-
#skipped? ⇒ Boolean
True if the operation was skipped due to existing lock.
-
#success? ⇒ Boolean
True if executed successfully without error.
Constructor Details
#initialize(executed:, value: nil, skipped: false, error: nil) ⇒ Result
Returns a new instance of Result.
17 18 19 20 21 22 |
# File 'lib/idempotency_lock/result.rb', line 17 def initialize(executed:, value: nil, skipped: false, error: nil) @executed = executed @value = value @skipped = skipped @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
15 16 17 |
# File 'lib/idempotency_lock/result.rb', line 15 def error @error end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
15 16 17 |
# File 'lib/idempotency_lock/result.rb', line 15 def value @value end |
Instance Method Details
#error? ⇒ Boolean
Returns true if an error occurred during execution.
35 36 37 |
# File 'lib/idempotency_lock/result.rb', line 35 def error? !@error.nil? end |
#executed? ⇒ Boolean
Returns true if the block was executed.
25 26 27 |
# File 'lib/idempotency_lock/result.rb', line 25 def executed? @executed end |
#inspect ⇒ String
Returns human-readable representation for debugging.
45 46 47 48 49 50 51 |
# File 'lib/idempotency_lock/result.rb', line 45 def inspect parts = ["executed=#{@executed}"] parts << "skipped=#{@skipped}" if @skipped parts << "value=#{@value.inspect}" if @value parts << "error=#{@error.class}" if @error "#<IdempotencyLock::Result #{parts.join(" ")}>" end |
#skipped? ⇒ Boolean
Returns true if the operation was skipped due to existing lock.
30 31 32 |
# File 'lib/idempotency_lock/result.rb', line 30 def skipped? @skipped end |
#success? ⇒ Boolean
Returns true if executed successfully without error.
40 41 42 |
# File 'lib/idempotency_lock/result.rb', line 40 def success? @executed && !error? end |