Class: Qo::Branches::MonadicWhenBranch
- Defined in:
- lib/qo/branches/monadic_when_branch.rb
Overview
Based on the where
branch, except deals with monadic values by attempting
to extract the value
before yielding to the given function on a match:
Matcher.new.call(Some[1]) { |m|
m.where(Some) { |v| v + 2 }
}
# => 3
Constant Summary
Constants inherited from Branch
Instance Attribute Summary
Attributes inherited from Branch
Instance Method Summary collapse
-
#initialize(destructure: false, extractor: :value) ⇒ MonadicWhenBranch
constructor
A new instance of MonadicWhenBranch.
Methods inherited from Branch
create, #create_matcher, #default?
Constructor Details
#initialize(destructure: false, extractor: :value) ⇒ MonadicWhenBranch
Returns a new instance of MonadicWhenBranch
16 17 18 19 20 21 22 23 |
# File 'lib/qo/branches/monadic_when_branch.rb', line 16 def initialize(destructure: false, extractor: :value) super( name: 'where', destructure: destructure, extractor: extractor, default: false, ) end |