Class: Result
- Inherits:
-
Object
- Object
- Result
- Defined in:
- lib/wolf_core/utils/result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#error ⇒ Object
Returns the value of attribute error.
Class Method Summary collapse
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(success:, data: nil, error: nil) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(success:, data: nil, error: nil) ⇒ Result
Returns a new instance of Result.
4 5 6 7 8 |
# File 'lib/wolf_core/utils/result.rb', line 4 def initialize(success:, data: nil, error: nil) @success = success @data = data @error = error end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/wolf_core/utils/result.rb', line 2 def data @data end |
#error ⇒ Object
Returns the value of attribute error.
2 3 4 |
# File 'lib/wolf_core/utils/result.rb', line 2 def error @error end |
Class Method Details
Instance Method Details
#failure? ⇒ Boolean
22 23 24 |
# File 'lib/wolf_core/utils/result.rb', line 22 def failure? !@success end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/wolf_core/utils/result.rb', line 18 def success? @success end |
#to_h ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/wolf_core/utils/result.rb', line 26 def to_h { success: @success, data: @data, error: @error, } end |