Skip to content

Instantly share code, notes, and snippets.

@liaden
Created November 13, 2014 18:00
Show Gist options
  • Save liaden/a6a8a743204fc23eb494 to your computer and use it in GitHub Desktop.
Save liaden/a6a8a743204fc23eb494 to your computer and use it in GitHub Desktop.
Tee.rb
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