Class: Kind::Maybe::Monad::Wrapper

Inherits:
Kind::Monad::Wrapper show all
Defined in:
lib/kind/maybe/monad/wrapper.rb

Instance Method Summary collapse

Methods inherited from Kind::Monad::Wrapper

#initialize, #output, #output?

Constructor Details

This class inherits a constructor from Kind::Monad::Wrapper

Instance Method Details

#none(matcher = UNDEFINED) ⇒ Object



7
8
9
10
11
# File 'lib/kind/maybe/monad/wrapper.rb', line 7

def none(matcher = UNDEFINED)
  return if @monad.some? || output?

  @output = yield(@monad.value) if @monad.maybe?(matcher)
end

#some(matcher = UNDEFINED) ⇒ Object



13
14
15
16
17
# File 'lib/kind/maybe/monad/wrapper.rb', line 13

def some(matcher = UNDEFINED)
  return if @monad.none? || output?

  @output = yield(@monad.value) if @monad.maybe?(matcher)
end