Module: Zx::Maybe::ClassMethods

Included in:
Zx, Zx, Zx::Maybeable, Zx::Maybeable
Defined in:
lib/zx/maybe.rb

Constant Summary collapse

None =
->(value = nil) { Zx::Maybe::None.new(value) }
Some =
->(*kwargs) { Zx::Maybe::Some.new(*kwargs) }
Maybe =
->(*kwargs) { Zx::Maybe.of(*kwargs) }

Instance Method Summary collapse

Instance Method Details

#Maybe(*kwargs) ⇒ Object



180
181
182
# File 'lib/zx/maybe.rb', line 180

def Maybe(*kwargs)
  Maybe[*kwargs]
end

#None(value = nil) ⇒ Object



188
189
190
# File 'lib/zx/maybe.rb', line 188

def None(value = nil)
  Zx::Maybe.of(value)
end

#Some(*kwargs) ⇒ Object



184
185
186
# File 'lib/zx/maybe.rb', line 184

def Some(*kwargs)
  Some[*kwargs]
end

#Try(default = nil, options = {}) ⇒ Object



192
193
194
195
196
# File 'lib/zx/maybe.rb', line 192

def Try(default = nil, options = {})
  Some[yield]
rescue StandardError => e
  None[default || options.fetch(:or, nil)]
end