Module: TypedCache::Either
- Includes:
- Kernel
- Defined in:
- lib/typed_cache/either.rb
Overview
Class Method Summary collapse
-
.left(error) ⇒ Object
: [E] (E) -> either[E, bot].
-
.right(value) ⇒ Object
: [R] ® -> either[bot, R].
-
.wrap(value, error_class = StandardError) ⇒ Object
: [E, R] (E | R) -> either[E, R].
Class Method Details
.left(error) ⇒ Object
: [E] (E) -> either[E, bot]
11 12 |
# File 'lib/typed_cache/either.rb', line 11 def left(error) = Left.new(error) #: [R] (R) -> either[bot, R] |
.right(value) ⇒ Object
: [R] ® -> either[bot, R]
13 |
# File 'lib/typed_cache/either.rb', line 13 def right(value) = Right.new(value) |
.wrap(value, error_class = StandardError) ⇒ Object
: [E, R] (E | R) -> either[E, R]
16 17 18 19 20 21 22 23 |
# File 'lib/typed_cache/either.rb', line 16 def wrap(value, error_class = StandardError) case value when Left, Right then value when error_class then Left.new(value) else Right.new(value) end end |