Module: Philiprehberger::Result::Tappable
Overview
Side-effect methods for Ok and Err results.
Instance Method Summary collapse
-
#tap_err {|error| ... } ⇒ self
Execute a side-effect on Err without changing the result.
-
#tap_ok {|value| ... } ⇒ self
Execute a side-effect on Ok value without changing the result.
Instance Method Details
#tap_err {|error| ... } ⇒ self
Execute a side-effect on Err without changing the result.
20 21 22 23 |
# File 'lib/philiprehberger/result/tappable.rb', line 20 def tap_err(&block) block.call(@error) if err? self end |
#tap_ok {|value| ... } ⇒ self
Execute a side-effect on Ok value without changing the result.
11 12 13 14 |
# File 'lib/philiprehberger/result/tappable.rb', line 11 def tap_ok(&block) block.call(@value) if ok? self end |