Class: Deterministic::Either

Inherits:
Object
  • Object
show all
Includes:
Monad, PatternMatching
Defined in:
lib/deterministic/either.rb,
lib/deterministic/either/attempt_all.rb

Direct Known Subclasses

Failure, Success

Defined Under Namespace

Classes: AttemptAll

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PatternMatching

#match

Methods included from Monad

#==, #bind, #initialize, #join, #map, #to_s, #value

Class Method Details

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



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

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

Instance Method Details

#<<(other) ⇒ Object



22
23
24
25
# File 'lib/deterministic/either.rb', line 22

def <<(other)
  return self if failure?
  return other if other.is_a? Either
end

#failure?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/deterministic/either.rb', line 18

def failure?
  is_a? Failure
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/deterministic/either.rb', line 14

def success?
  is_a? Success
end