Class: CallSheet::ResultMatcher
- Inherits:
-
Object
- Object
- CallSheet::ResultMatcher
- Defined in:
- lib/call_sheet/result_matcher.rb
Defined Under Namespace
Classes: FailureMatcher
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #failure(&block) ⇒ Object
-
#initialize(result) ⇒ ResultMatcher
constructor
A new instance of ResultMatcher.
- #success(&block) ⇒ Object
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
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/call_sheet/result_matcher.rb', line 3 def result @result end |
#value ⇒ Object (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 |