Module: Fear::Try::Mixin
- Included in:
- Mixin
- Defined in:
- lib/fear/try.rb
Overview
Include this mixin to access convenient factory methods.
Instance Method Summary collapse
- #Failure(exception) ⇒ Failure
- #Success(value) ⇒ Success
-
#Try ⇒ Try
Constructs a
Tryusing the block.
Instance Method Details
#Failure(exception) ⇒ Failure
290 291 292 |
# File 'lib/fear/try.rb', line 290 def Failure(exception) Failure.new(exception) end |
#Success(value) ⇒ Success
297 298 299 |
# File 'lib/fear/try.rb', line 297 def Success(value) Success.new(value) end |
#Try ⇒ Try
Constructs a Try using the block. This method will ensure any non-fatal exception )is caught and a Failure object is returned.
281 282 283 284 285 |
# File 'lib/fear/try.rb', line 281 def Try Success.new(yield) rescue StandardError => error Failure.new(error) end |