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