Class: CallSheet::ResultMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/call_sheet/result_matcher.rb

Defined Under Namespace

Classes: FailureMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ResultMatcher

Returns a new instance of ResultMatcher.



6
7
8
9
# File 'lib/call_sheet/result_matcher.rb', line 6

def initialize(result)
  @result = result
  @value = result.value
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/call_sheet/result_matcher.rb', line 3

def result
  @result
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/call_sheet/result_matcher.rb', line 4

def value
  @value
end

Instance Method Details

#failure(&block) ⇒ Object



15
16
17
# File 'lib/call_sheet/result_matcher.rb', line 15

def failure(&block)
  block.call FailureMatcher.new(result) if result.is_a?(Kleisli::Either::Left)
end

#success(&block) ⇒ Object



11
12
13
# File 'lib/call_sheet/result_matcher.rb', line 11

def success(&block)
  block.call value if result.is_a?(Kleisli::Either::Right)
end