Module: Dry::Monads::Try::Mixin
- Includes:
- Constructors
- Defined in:
- lib/dry/monads/try.rb
Overview
A module that can be included for easier access to Try monads.
Defined Under Namespace
Modules: Constructors
Constant Summary collapse
- Try =
Try
Instance Method Summary collapse
-
#Error(error = Undefined, &block) ⇒ Object
Error constructor.
-
#Value(value = Undefined, exceptions = DEFAULT_EXCEPTIONS, &block) ⇒ Object
Value constructor.
Methods included from Constructors
Instance Method Details
#Error(value) ⇒ Try::Error #Error(&block) ⇒ Try::Error
Error constructor
306 307 308 309 310 311 |
# File 'lib/dry/monads/try.rb', line 306 def Error(error = Undefined, &block) v = Undefined.default(error, block) raise ArgumentError, "No value given" if v.nil? Try::Error.new(v) end |
#Value(value) ⇒ Try::Value #Value(&block) ⇒ Try::Value
Value constructor
289 290 291 292 293 294 |
# File 'lib/dry/monads/try.rb', line 289 def Value(value = Undefined, exceptions = DEFAULT_EXCEPTIONS, &block) v = Undefined.default(value, block) raise ArgumentError, "No value given" if !value.nil? && v.nil? Try::Value.new(exceptions, v) end |