Class: MPrelude::Either

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat, Functor
Defined in:
lib/mprelude.rb

Overview

Maybe

Direct Known Subclasses

Left, Right

Defined Under Namespace

Classes: Left, Right

Class Method Summary collapse

Class Method Details

.wrap_error(error) ⇒ Either<Exception, Object>

Execute block and wrap error in left

Parameters:

  • error (Class:Exception)

Returns:



86
87
88
89
90
# File 'lib/mprelude.rb', line 86

def self.wrap_error(error)
  Right.new(yield)
rescue error => exception
  Left.new(exception)
end