Class: Monadify::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/monadify/option/option.rb

Overview

use: Option.from { execute block }

Direct Known Subclasses

None, Some

Class Method Summary collapse

Class Method Details

.fromObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/monadify/option/option.rb', line 3

def self.from
  begin
    val = yield
    if val.nil?
      Monadify::None.new
    else
      Monadify::Some.new(val)
    end
  rescue
    Monadify::None.new
  end
end