Skip to content

Instantly share code, notes, and snippets.

@XrXr
Last active April 10, 2019 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XrXr/dc78220bdb01057ea194c4a97069648f to your computer and use it in GitHub Desktop.
Save XrXr/dc78220bdb01057ea194c4a97069648f to your computer and use it in GitHub Desktop.
A way to catch calls to Kernel#puts
module Kernel
original_puts = instance_method(:puts)
define_method(:puts) do |*args|
$stdout.puts("how are you doing")
# binding.pry
original_puts.bind(self).call(*args)
end
end
puts "I'm doing fine thanks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment