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