Class: Kind::Result::Monad::Wrapper

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

Instance Method Summary collapse

Methods inherited from Monad::Wrapper

#initialize, #output, #output?

Constructor Details

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

Instance Method Details

#failure(types = Undefined, matcher = Undefined) ⇒ Object



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

def failure(types = Undefined, matcher = Undefined)
  return if @monad.success? || output?

  @output = yield(@monad.value) if @monad.result?(types, matcher)
end

#success(types = Undefined, matcher = Undefined) ⇒ Object



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

def success(types = Undefined, matcher = Undefined)
  return if @monad.failure? || output?

  @output = yield(@monad.value) if @monad.result?(types, matcher)
end