Class: Dry::ResultMatcher::Matcher
- Inherits:
-
Object
- Object
- Dry::ResultMatcher::Matcher
- Defined in:
- lib/dry/result_matcher/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(&block) ⇒ Object
-
#initialize(result) ⇒ Matcher
constructor
A new instance of Matcher.
- #success(&block) ⇒ Object
Constructor Details
#initialize(result) ⇒ Matcher
Returns a new instance of Matcher.
9 10 11 |
# File 'lib/dry/result_matcher/matcher.rb', line 9 def initialize(result) @result = result end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/dry/result_matcher/matcher.rb', line 7 def output @output end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/dry/result_matcher/matcher.rb', line 6 def result @result end |
Instance Method Details
#failure(&block) ⇒ Object
18 19 20 21 |
# File 'lib/dry/result_matcher/matcher.rb', line 18 def failure(&block) return output unless result.is_a?(Kleisli::Either::Left) @output = block.call(result.value) end |
#success(&block) ⇒ Object
13 14 15 16 |
# File 'lib/dry/result_matcher/matcher.rb', line 13 def success(&block) return output unless result.is_a?(Kleisli::Either::Right) @output = block.call(result.value) end |