Class: Fear::TryPatternMatch Private
- Inherits:
-
PatternMatch
- Object
- PatternMatch
- Fear::TryPatternMatch
- Defined in:
- lib/fear/try_pattern_match.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
it has two optimized subclasses Fear::SuccessPatternMatch
and Fear::FailurePatternMatch
Try pattern matcher
Direct Known Subclasses
Constant Summary collapse
- SUCCESS_EXTRACTOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:get.to_proc
- FAILURE_EXTRACTOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:exception.to_proc
Instance Attribute Summary
Attributes inherited from PatternMatch
Instance Method Summary collapse
-
#failure(*conditions, &effect) ⇒ Fear::TryPatternMatch
private
Match against
Fear::Failure
. -
#success(*conditions, &effect) ⇒ Fear::TryPatternMatch
private
Match against
Fear::Success
.
Methods inherited from PatternMatch
__new__, #case, #else, #initialize, mixin, new, #or_else, #xcase
Constructor Details
This class inherits a constructor from Fear::PatternMatch
Instance Method Details
#failure(*conditions, &effect) ⇒ Fear::TryPatternMatch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Match against Fear::Failure
25 26 27 28 |
# File 'lib/fear/try_pattern_match.rb', line 25 def failure(*conditions, &effect) branch = Fear.case(Fear::Failure, &FAILURE_EXTRACTOR).and_then(Fear.case(*conditions, &effect)) or_else(branch) end |
#success(*conditions, &effect) ⇒ Fear::TryPatternMatch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Match against Fear::Success
16 17 18 19 |
# File 'lib/fear/try_pattern_match.rb', line 16 def success(*conditions, &effect) branch = Fear.case(Fear::Success, &SUCCESS_EXTRACTOR).and_then(Fear.case(*conditions, &effect)) or_else(branch) end |