Module: Deterministic::Either

Defined in:
lib/deterministic/either.rb,
lib/deterministic/either/match.rb,
lib/deterministic/either/failure.rb,
lib/deterministic/either/success.rb,
lib/deterministic/either/attempt_all.rb

Defined Under Namespace

Classes: AttemptAll, Either, Failure, Match, Success

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attempt_all(context = OpenStruct.new, &block) ⇒ Object



3
4
5
# File 'lib/deterministic/either/attempt_all.rb', line 3

def self.attempt_all(context=OpenStruct.new, &block)
  AttemptAll.new(context, &block).call
end

Instance Method Details

#Failure(value) ⇒ Object



6
7
8
# File 'lib/deterministic/either.rb', line 6

def Failure(value)
  Failure.unit(value)
end

#match(proc = nil, &block) ⇒ Object



2
3
4
5
6
# File 'lib/deterministic/either/match.rb', line 2

def match(proc=nil, &block)
  match = Match.new(self)
  match.instance_eval &(proc || block)
  match.result
end

#Success(value) ⇒ Object



2
3
4
# File 'lib/deterministic/either.rb', line 2

def Success(value)
  Success.unit(value)
end