Class: Dyph::Outcome::Resolved

Inherits:
Dyph::Outcome show all
Defined in:
lib/dyph/outcome/resolved.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Dyph::Outcome

#conflicted?, #resolved?

Constructor Details

#initialize(result) ⇒ Resolved

Returns a new instance of Resolved.



4
5
6
7
# File 'lib/dyph/outcome/resolved.rb', line 4

def initialize(result)
  @result = result
  @combiner = ->(x, y) { x + y }
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/dyph/outcome/resolved.rb', line 3

def result
  @result
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



13
14
15
16
# File 'lib/dyph/outcome/resolved.rb', line 13

def ==(other)
  self.class == other.class &&
  self.result == other.result
end

#apply(fun) ⇒ Object



29
30
31
# File 'lib/dyph/outcome/resolved.rb', line 29

def apply(fun)
   Outcome::Resolved.new(fun[result])
end

#combine(other) ⇒ Object



24
25
26
27
# File 'lib/dyph/outcome/resolved.rb', line 24

def combine(other)
   @result = @combiner[@result, other.result]
   self
end

#hashObject



20
21
22
# File 'lib/dyph/outcome/resolved.rb', line 20

def hash
  self.result.hash
end

#set_combiner(lambda) ⇒ Object



9
10
11
# File 'lib/dyph/outcome/resolved.rb', line 9

def set_combiner(lambda)
  @combiner = lambda
end