Module: Deterministic::Either::Chain

Included in:
Deterministic::Either
Defined in:
lib/deterministic/either/chain.rb

Instance Method Summary collapse

Instance Method Details

#chain(proc = nil, &block) ⇒ Object Also known as: >>



4
5
6
7
# File 'lib/deterministic/either/chain.rb', line 4

def chain(proc=nil, &block)
  return self if failure?
  bind { (proc || block).call(@value) }
end

#try(proc = nil, &block) ⇒ Object Also known as: >=



11
12
13
14
15
16
# File 'lib/deterministic/either/chain.rb', line 11

def try(proc=nil, &block)
  return self if failure?
  bind { (proc || block).call(@value) }
rescue => err
  Failure(err)
end