From: Simon Strandgaard Date: 2004-01-21T06:55:01+09:00 Subject: enable debugflag in module To ease unittesting I have made a #debug keyword, which enables the global $debug flag for the specified method. For instance debug :test is roughly equivalent with def test $debug = true super $debug = false end The "debug" keyword works inside classes. But not within modules. Question: How can I make "debug" work within modules ? -- Simon Strandgaard server> ruby a.rb before #test 42 after #test server> expand -t4 a.rb class Object # enable the global debug flag for just a single method def self.debug(*args) args.each{|symbol| begin meth = instance_method(symbol) rescue => e $stderr.puts "ERROR: symbol2method failure, " + e.inspect next end name = symbol.id2name org = "_debug_"+name arguments = (meth.arity != 0) ? "(*a,&b)" : "(&b)" module_eval <