Class: MultiResult
- Inherits:
-
Object
- Object
- MultiResult
- Defined in:
- lib/familia/multi_result.rb
Overview
The magical MultiResult, keeper of Redis’s deepest secrets!
This quirky little class wraps up the outcome of a Database “transaction” (or as I like to call it, a “Database dance party”) with a bow made of pure Ruby delight. It knows if your commands were successful and keeps the results safe in its pocket dimension.
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.
-
#successful? ⇒ Boolean
(also: #success?)
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.
42 43 44 45 |
# File 'lib/familia/multi_result.rb', line 42 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.
30 31 32 |
# File 'lib/familia/multi_result.rb', line 30 def results @results end |
#success ⇒ Boolean (readonly)
Returns true if all commands in the transaction succeeded, false otherwise.
30 31 32 |
# File 'lib/familia/multi_result.rb', line 30 def success @success end |
Instance Method Details
#successful? ⇒ Boolean Also known as: success?
Convenient method to check if the commit was successful.
68 69 70 |
# File 'lib/familia/multi_result.rb', line 68 def successful? @success end |
#to_h ⇒ Object
61 62 63 |
# File 'lib/familia/multi_result.rb', line 61 def to_h { success: successful?, results: results } end |
#tuple ⇒ Array Also known as: to_a
Returns a tuple representing the result of the transaction.
56 57 58 |
# File 'lib/familia/multi_result.rb', line 56 def tuple [successful?, results] end |