Module: Fear::Option::Mixin

Included in:
Mixin
Defined in:
lib/fear/option.rb

Overview

Include this mixin to access convenient factory methods.

Examples:

include Fear::Option::Mixin

Option(17) #=> #<Fear::Some get=17>
Option(nil) #=> #<Fear::None>
Some(17) #=> #<Fear::Some get=17>
None() #=> #<Fear::None>

Instance Method Summary collapse

Instance Method Details

#NoneNone

Examples:

None() #=> #<Fear::None>

223
224
225
# File 'lib/fear/option.rb', line 223

def None
  Fear.none
end

#Option(value) ⇒ Fear::Some, Fear::None

An Option factory which creates Some if the argument is not nil, and None if it is nil.

Examples:

Option(17) #=> #<Fear::Some get=17>
Option(nil) #=> #<Fear::None>

215
216
217
# File 'lib/fear/option.rb', line 215

def Option(value)
  Fear.option(value)
end

#Some(value) ⇒ Fear::Some

Examples:

Some(17) #=> #<Fear::Some get=17>
Some(nil) #=> #<Fear::Some get=nil>

233
234
235
# File 'lib/fear/option.rb', line 233

def Some(value)
  Fear.some(value)
end