Class: CallSheet::ResultMatcher
- Inherits:
-
Object
- Object
- CallSheet::ResultMatcher
- Defined in:
- lib/call_sheet/result_matcher.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #failure(step_name = nil, &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 |
# File 'lib/call_sheet/result_matcher.rb', line 6 def initialize(result) @result = result end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
4 5 6 |
# File 'lib/call_sheet/result_matcher.rb', line 4 def output @output end |
#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 |
Instance Method Details
#failure(step_name = nil, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/call_sheet/result_matcher.rb', line 16 def failure(step_name = nil, &block) return output unless result.is_a?(Kleisli::Either::Left) if step_name.nil? || step_name == result.value.__step_name @output = block.call(result.value) end end |
#success(&block) ⇒ Object
10 11 12 13 14 |
# File 'lib/call_sheet/result_matcher.rb', line 10 def success(&block) return output unless result.is_a?(Kleisli::Either::Right) @output = block.call(result.value) end |