Class: MultiResult
- Inherits:
-
Object
- Object
- MultiResult
- Defined in:
- lib/multi_result.rb
Overview
Represents the result of a Valkey/Redis transaction operation.
This class encapsulates the outcome of a Database transaction, providing access to both the success status and the individual command results returned by the transaction.
Instance Attribute Summary collapse
-
#results ⇒ Array<String>
readonly
The raw return values from the Database commands.
-
#success ⇒ Boolean
readonly
True if all commands in the transaction succeeded, false otherwise.
Instance Method Summary collapse
-
#initialize(success, results) ⇒ MultiResult
constructor
Creates a new MultiResult instance.
-
#size ⇒ Integer
Returns the number of results in the multi-operation.
-
#successful? ⇒ Boolean
(also: #success?, #areyouhappynow?)
Convenient method to check if the commit was successful.
- #to_h ⇒ Object
-
#tuple ⇒ Array
(also: #to_a)
Returns a tuple representing the result of the transaction.
Constructor Details
#initialize(success, results) ⇒ MultiResult
Creates a new MultiResult instance.
43 44 45 46 |
# File 'lib/multi_result.rb', line 43 def initialize(success, results) @success = success @results = results end |
Instance Attribute Details
#results ⇒ Array<String> (readonly)
Returns The raw return values from the Database commands.
31 32 33 |
# File 'lib/multi_result.rb', line 31 def results @results end |
#success ⇒ Boolean (readonly)
Returns true if all commands in the transaction succeeded, false otherwise.
31 32 33 |
# File 'lib/multi_result.rb', line 31 def success @success end |
Instance Method Details
#size ⇒ Integer
Returns the number of results in the multi-operation.
65 66 67 |
# File 'lib/multi_result.rb', line 65 def size results.size end |
#successful? ⇒ Boolean Also known as: success?, areyouhappynow?
Convenient method to check if the commit was successful.
76 77 78 |
# File 'lib/multi_result.rb', line 76 def successful? @success end |
#to_h ⇒ Object
69 70 71 |
# File 'lib/multi_result.rb', line 69 def to_h { success: successful?, results: results } end |
#tuple ⇒ Array Also known as: to_a
Returns a tuple representing the result of the transaction.
57 58 59 |
# File 'lib/multi_result.rb', line 57 def tuple [successful?, results] end |