Class: Fear::Try::PatternMatch Private
- Inherits:
-
PatternMatch
- Object
- PatternMatch
- Fear::Try::PatternMatch
- 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::Success::PatternMatch
and Fear::FailurePatternMatch
Try pattern matcher
Instance Attribute Summary
Attributes inherited from PatternMatch
Instance Method Summary collapse
-
#failure(*conditions, &effect) ⇒ Fear::Try::PatternMatch
private
Match against
Fear::Failure
. -
#success(*conditions, &effect) ⇒ Fear::Try::PatternMatch
private
Match against
Fear::Success
.
Methods inherited from PatternMatch
__new__, #case, #else, #initialize, mixin, new, #or_else
Constructor Details
This class inherits a constructor from Fear::PatternMatch
Instance Method Details
#failure(*conditions, &effect) ⇒ Fear::Try::PatternMatch
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
23 24 25 26 |
# File 'lib/fear/try/pattern_match.rb', line 23 def failure(*conditions, &effect) branch = Fear.case(Fear::Failure, &:exception).and_then(Fear.case(*conditions, &effect)) or_else(branch) end |
#success(*conditions, &effect) ⇒ Fear::Try::PatternMatch
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
14 15 16 17 |
# File 'lib/fear/try/pattern_match.rb', line 14 def success(*conditions, &effect) branch = Fear.case(Fear::Success, &:get).and_then(Fear.case(*conditions, &effect)) or_else(branch) end |