Class: Verbalize::Failure
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/verbalize/failure.rb
Instance Attribute Summary
Attributes inherited from Result
Instance Method Summary collapse
- #failure ⇒ Object
-
#initialize(failure) ⇒ Failure
constructor
A new instance of Failure.
- #value ⇒ Object
Methods inherited from Result
#failed?, #succeeded?, #to_ary
Constructor Details
#initialize(failure) ⇒ Failure
Returns a new instance of Failure.
8 9 10 |
# File 'lib/verbalize/failure.rb', line 8 def initialize(failure) super(outcome: :error, value: failure) end |
Instance Method Details
#failure ⇒ Object
12 13 14 |
# File 'lib/verbalize/failure.rb', line 12 def failure @value end |
#value ⇒ Object
16 17 18 19 20 |
# File 'lib/verbalize/failure.rb', line 16 def value raise Verbalize::Error, 'You called #value on a Failure result. You should never use `Verbalize::Action#call` ' \ 'without also explicitly handling potential errors. Please use `Verbalize::Action#call!` to return a value ' \ 'directly on successful execution of an action, or handle the error case explicitly if using `#call`.' end |