Class: Verbalize::Failure

Inherits:
Result
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/verbalize/failure.rb

Instance Attribute Summary

Attributes inherited from Result

#outcome

Instance Method Summary collapse

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

#failureObject



12
13
14
# File 'lib/verbalize/failure.rb', line 12

def failure
  @value
end

#valueObject

Raises:



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