Proxy Logging
Once in a while it helps to log the messages an object gets. I usually
use this trick:
require 'pp'
class LogProxy
def initialize(object)
@object = object
end
def method_missing(sym, *args, &block)
pp [args, block]
@object.send(sym, *args, &block)
end
end
I then wrap my object to be logged and watch the command line. It's a
simple trick, but often helps me debug object protocols.
posted on: 07/18/2006 | path: /tech