Class: Flows::Result::Ok
- Inherits:
-
Flows::Result
- Object
- Flows::Result
- Flows::Result::Ok
- Defined in:
- lib/flows/result/ok.rb
Overview
Wrapper for successful results
Instance Attribute Summary collapse
-
#unwrap ⇒ Object
readonly
Returns the value of attribute unwrap.
Attributes inherited from Flows::Result
Instance Method Summary collapse
- #err? ⇒ Boolean
- #error ⇒ Object
-
#initialize(data, status: :success, meta: {}) ⇒ Ok
constructor
A new instance of Ok.
- #ok? ⇒ Boolean
Constructor Details
#initialize(data, status: :success, meta: {}) ⇒ Ok
Returns a new instance of Ok.
7 8 9 10 11 |
# File 'lib/flows/result/ok.rb', line 7 def initialize(data, status: :success, meta: {}) @unwrap = data @status = status @meta = end |
Instance Attribute Details
#unwrap ⇒ Object (readonly)
Returns the value of attribute unwrap.
5 6 7 |
# File 'lib/flows/result/ok.rb', line 5 def unwrap @unwrap end |
Instance Method Details
#err? ⇒ Boolean
17 18 19 |
# File 'lib/flows/result/ok.rb', line 17 def err? false end |
#error ⇒ Object
21 22 23 |
# File 'lib/flows/result/ok.rb', line 21 def error raise NoErrorError.new(@status, @data) end |
#ok? ⇒ Boolean
13 14 15 |
# File 'lib/flows/result/ok.rb', line 13 def ok? true end |