class Fear::TryPatternMatch
Try
pattern matcher
@note it has two optimized subclasses Fear::SuccessPatternMatch
and Fear::FailurePatternMatch
@api private
Constants
- FAILURE_EXTRACTOR
- SUCCESS_EXTRACTOR
Public Instance Methods
failure(*conditions, &effect)
click to toggle source
Match against Fear::Failure
@param conditions [<#==>] @return [Fear::TryPatternMatch]
# File lib/fear/try_pattern_match.rb, line 28 def failure(*conditions, &effect) branch = Fear.case(Fear::Failure, &FAILURE_EXTRACTOR).and_then(Fear.case(*conditions, &effect)) or_else(branch) end
success(*conditions, &effect)
click to toggle source
Match against Fear::Success
@param conditions [<#==>] @return [Fear::TryPatternMatch]
# File lib/fear/try_pattern_match.rb, line 19 def success(*conditions, &effect) branch = Fear.case(Fear::Success, &SUCCESS_EXTRACTOR).and_then(Fear.case(*conditions, &effect)) or_else(branch) end