Skip to content

Instantly share code, notes, and snippets.

@Bill Bill/gist:96776
Created Apr 17, 2009

Embed
What would you like to do?
# capture a yaml dump of an object like this:
# capture { y request }
module Kernel
def capture # pass a block to capture
old_stdout = $stdout
out = StringIO.new
$stdout = out
begin
yield
ensure
$stdout = old_stdout
end
out.string
end
module_function :capture
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.