Class: HatiCommand::Success
- Defined in:
- lib/hati_command/success.rb
Overview
Represents a successful result in the Result pattern. This class is used to wrap successful operation values and provide a consistent interface for handling both successful and failed operations.
The Success class is part of the Result pattern implementation, working alongside the Failure class to provide a type-safe way to handle operation outcomes.
Instance Attribute Summary
Attributes inherited from Result
Instance Method Summary collapse
-
#failure ⇒ nil
Returns nil since a Success has no failure value.
-
#failure? ⇒ Boolean
Indicates that this is not a failure result.
-
#success ⇒ Object
Returns the success value wrapped by this Success instance.
-
#success? ⇒ Boolean
Indicates that this is a success result.
-
#to_sym ⇒ Symbol
Returns the symbolic representation of this result type.
Methods inherited from Result
Constructor Details
This class inherits a constructor from HatiCommand::Result
Instance Method Details
#failure ⇒ nil
Returns nil since a Success has no failure value. This method is part of the Result pattern interface and always returns nil for Success instances.
67 68 69 |
# File 'lib/hati_command/success.rb', line 67 def failure nil end |
#failure? ⇒ Boolean
Indicates that this is not a failure result. This method is part of the Result pattern interface and always returns false for Success instances.
79 80 81 |
# File 'lib/hati_command/success.rb', line 79 def failure? false end |
#success ⇒ Object
Returns the success value wrapped by this Success instance. This method provides access to the actual value or result that was produced by the successful operation.
43 44 45 |
# File 'lib/hati_command/success.rb', line 43 def success value end |
#success? ⇒ Boolean
Indicates that this is a success result. This method is part of the Result pattern interface and always returns true for Success instances.
55 56 57 |
# File 'lib/hati_command/success.rb', line 55 def success? true end |
#to_sym ⇒ Symbol
Returns the symbolic representation of this result type. Useful for pattern matching and result type checking.
91 92 93 |
# File 'lib/hati_command/success.rb', line 91 def to_sym :success end |