class Qo::PatternMatchers::ResultPatternMatch
Unlike the normal pattern matcher, this one works on tuple arrays containing a status and a result like `[:ok, result]` and `[:err, message]`.
Note that each of these can still take conditionals much like a `where` branch for more fine grained control over what we're looking for.
@example
```ruby matcher = Qo.result_match { |m| m.success(String) { |v| "Hello #{v}"} m.success { |v| v + 10 } m.failure { |v| "Error: #{v}" } } matcher.call([:ok, 'there']) # => "Hello there" matcher.call([:ok, 4]) # => 14 matcher.call([:err, 'OH NO']) # => "Error: OH NO" ```
@author baweaver @since 1.0.0
Public Class Methods
new(destructure: false)
click to toggle source
Creates a new result matcher
@param destructure: false [Boolean]
Whether or not to destructure the value before yielding to the first matched block
@return [type] [description]
Calls superclass method
Qo::PatternMatchers::PatternMatch::new
# File lib/qo/pattern_matchers/result_pattern_match.rb, line 40 def initialize(destructure: false) super(destructure: destructure) end