Class: Qo::Branches::FailureBranch
- Defined in:
- lib/qo/branches/failure_branch.rb
Overview
A tuple branch that will be triggered when the first value is
:err
.
ResultPatternMatch.new { |m|
m.failure { |v| "This is the error: #{v}" }
}.call([:err, 'OH NO!'])
# => "This is the error: OH NO!"
Constant Summary
Constants inherited from Branch
Instance Attribute Summary
Attributes inherited from Branch
Instance Method Summary collapse
-
#initialize(destructure: false) ⇒ FailureBranch
constructor
A new instance of FailureBranch.
Methods inherited from Branch
create, #create_matcher, #default?
Constructor Details
#initialize(destructure: false) ⇒ FailureBranch
Returns a new instance of FailureBranch
16 17 18 19 20 21 22 23 |
# File 'lib/qo/branches/failure_branch.rb', line 16 def initialize(destructure: false) super( name: 'failure', destructure: destructure, precondition: -> v { v.first == :err }, extractor: :last, ) end |