Class: MPrelude::Either
- Inherits:
-
Object
- Object
- MPrelude::Either
- Includes:
- AbstractType, Adamantium::Flat, RequireBlock
- Defined in:
- lib/mprelude.rb
Overview
Maybe
Defined Under Namespace
Class Method Summary collapse
-
.wrap_error(*exceptions) ⇒ Either<Exception, Object>
Execute block and wrap error in left.
Instance Method Summary collapse
-
#left? ⇒ Boolean
Test for left constructor.
-
#right? ⇒ Boolean
Test for right constructor.
Class Method Details
.wrap_error(*exceptions) ⇒ Either<Exception, Object>
Execute block and wrap error in left
84 85 86 87 88 |
# File 'lib/mprelude.rb', line 84 def self.wrap_error(*exceptions) Right.new(yield) rescue *exceptions => error Left.new(error) end |
Instance Method Details
#left? ⇒ Boolean
Test for left constructor
93 94 95 |
# File 'lib/mprelude.rb', line 93 def left? instance_of?(Left) end |
#right? ⇒ Boolean
Test for right constructor
100 101 102 |
# File 'lib/mprelude.rb', line 100 def right? instance_of?(Right) end |