Created
November 13, 2014 18:00
-
-
Save liaden/a6a8a743204fc23eb494 to your computer and use it in GitHub Desktop.
Tee.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
# as inspired by bash | |
def tee(*functions) | |
self.tap do | |
args.map { |arg| arg.call(self) } | |
end | |
end | |
end | |
class SomeClass | |
def g | |
"return value" | |
end | |
def f | |
g.tee(logger.method(:debug)) | |
end | |
end | |
SomeClass.new.f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment