Class: LaunchDarkly::Result
- Inherits:
-
Object
- Object
- LaunchDarkly::Result
- Defined in:
- lib/ldclient-rb/util.rb
Overview
A Result is used to reflect the outcome of any operation.
Results can either be considered a success or a failure.
In the event of success, the Result will contain an option, nullable value to hold any success value back to the calling function.
If the operation fails, the Result will contain an error describing the value.
Instance Attribute Summary collapse
-
#error ⇒ String?
readonly
An error description of the failure; nil otherwise.
-
#exception ⇒ Exception?
readonly
An optional exception which caused the failure.
-
#value ⇒ Object?
readonly
The value returned from the operation if it was successful; nil otherwise.
Class Method Summary collapse
-
.fail(error, exception = nil) ⇒ Result
Create a failed result with the provided error description.
-
.success(value) ⇒ Result
Create a successful result with the provided value.
Instance Method Summary collapse
-
#success? ⇒ Boolean
Was this result successful or did it encounter an error?.
Instance Attribute Details
#error ⇒ String? (readonly)
Returns An error description of the failure; nil otherwise.
54 55 56 |
# File 'lib/ldclient-rb/util.rb', line 54 def error @error end |
#exception ⇒ Exception? (readonly)
Returns An optional exception which caused the failure.
59 60 61 |
# File 'lib/ldclient-rb/util.rb', line 59 def exception @exception end |
#value ⇒ Object? (readonly)
Returns The value returned from the operation if it was successful; nil otherwise.
49 50 51 |
# File 'lib/ldclient-rb/util.rb', line 49 def value @value end |
Class Method Details
Instance Method Details
#success? ⇒ Boolean
Was this result successful or did it encounter an error?
42 43 44 |
# File 'lib/ldclient-rb/util.rb', line 42 def success? @error.nil? end |