Class: Statefully::State::Failure
- Inherits:
-
Statefully::State
- Object
- Statefully::State
- Statefully::State::Failure
- Defined in:
- lib/statefully/state.rb
Overview
Failure is a failed Statefully::State.
Instance Attribute Summary collapse
-
#error ⇒ StandardError
readonly
Error stored in the current Statefully::State.
Attributes inherited from Statefully::State
Instance Method Summary collapse
-
#diff ⇒ Diff::Failed
Return a Diff between current and previous Statefully::State.
-
#initialize(values, error, previous:) ⇒ Failure
constructor
private
Constructor for the Failure object.
-
#inspect ⇒ String
Show the current Statefully::State in a human-readable form.
-
#resolve ⇒ State
Resolve the current Statefully::State.
-
#successful? ⇒ Boolean
Check if the current Statefully::State is successful.
Methods inherited from Statefully::State
#ancestry, create, #each, #failed?, #fetch, #finished?, #history, #key?, #keys, #none?
Constructor Details
#initialize(values, error, previous:) ⇒ Failure
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constructor for the Statefully::State::Failure object
409 410 411 412 |
# File 'lib/statefully/state.rb', line 409 def initialize(values, error, previous:) super(values, previous: previous) @error = error end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Statefully::State
Instance Attribute Details
#error ⇒ StandardError (readonly)
Error stored in the current Statefully::State
401 402 403 |
# File 'lib/statefully/state.rb', line 401 def error @error end |
Instance Method Details
#diff ⇒ Diff::Failed
Return a Diff between current and previous Statefully::State
422 423 424 |
# File 'lib/statefully/state.rb', line 422 def diff Diff::Failed.new(error).freeze end |
#inspect ⇒ String
Show the current Statefully::State in a human-readable form
468 469 470 |
# File 'lib/statefully/state.rb', line 468 def inspect _inspect_details(error: error.inspect) end |
#resolve ⇒ State
Resolve the current Statefully::State
Resolving will return the current Statefully::State if successful, but raise an error wrapped in a Statefully::State::Failure. This is a convenience method inspired by monadic composition from functional languages.
457 458 459 |
# File 'lib/statefully/state.rb', line 457 def resolve raise error end |
#successful? ⇒ Boolean
Check if the current Statefully::State is successful
437 438 439 |
# File 'lib/statefully/state.rb', line 437 def successful? false end |