Class: Cuprum::Result
- Inherits:
-
Object
- Object
- Cuprum::Result
- Defined in:
- lib/cuprum/result.rb
Overview
Data object that encapsulates the result of calling a Cuprum function or operation.
Instance Attribute Summary collapse
-
#errors ⇒ Array
The errors (if any) generated when the function was called.
-
#value ⇒ Object
The value returned by calling the function.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
False if the function did not generate any errors, otherwise true.
-
#success? ⇒ Boolean
True if the function did not generate any errors, otherwise false.
Instance Attribute Details
#errors ⇒ Array
Returns the errors (if any) generated when the function was called.
14 15 16 |
# File 'lib/cuprum/result.rb', line 14 def errors @errors ||= [] end |
#value ⇒ Object
Returns the value returned by calling the function.
8 9 10 |
# File 'lib/cuprum/result.rb', line 8 def value @value end |
Instance Method Details
#failure? ⇒ Boolean
Returns false if the function did not generate any errors, otherwise true.
20 21 22 |
# File 'lib/cuprum/result.rb', line 20 def failure? !errors.empty? end |
#success? ⇒ Boolean
Returns true if the function did not generate any errors, otherwise false.
26 27 28 |
# File 'lib/cuprum/result.rb', line 26 def success? errors.empty? end |