Class: Opted::Result::Match::MatchWithBranchChecking
- Inherits:
-
Object
- Object
- Opted::Result::Match::MatchWithBranchChecking
- Defined in:
- lib/opted/result/match.rb
Instance Method Summary collapse
- #err(&block) ⇒ Object
-
#initialize(match) ⇒ MatchWithBranchChecking
constructor
A new instance of MatchWithBranchChecking.
- #mapped_value_or_error ⇒ Object
- #ok(&block) ⇒ Object
Constructor Details
#initialize(match) ⇒ MatchWithBranchChecking
Returns a new instance of MatchWithBranchChecking.
53 54 55 |
# File 'lib/opted/result/match.rb', line 53 def initialize(match) @match = match end |
Instance Method Details
#err(&block) ⇒ Object
62 63 64 65 |
# File 'lib/opted/result/match.rb', line 62 def err(&block) @err_called = true @match.err(&block) end |
#mapped_value_or_error ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/opted/result/match.rb', line 67 def mapped_value_or_error if @ok_called && @err_called @match.mapped_value_or_error else fail "Must match on both ok and err results" end end |
#ok(&block) ⇒ Object
57 58 59 60 |
# File 'lib/opted/result/match.rb', line 57 def ok(&block) @ok_called = true @match.ok(&block) end |