On Fri, 07 Nov 2003 13:47:16 +0100, Simon Strandgaard wrote:
[snip]
> But I don't like this current approach (files appears to be modified in
> CVS). Instead I _dream_ of a 'debug' keyword, which would set a debug-flag
> variable for the specified methods. I imagine something like:
> 
> 	class TestScanner < Test::Unit::TestCase
> 		include Repeat
> 		debug test_repeat8, test_repeat9
> 	end
> 

I solved it myself.. Thanks comp.lang.ruby ;-) 

--
Simon Strandgaard


server> ruby debug_keyword.rb
before
42
after
server> exp
expand expr   
server> expand -t2 debug_keyword.rb 
class Test
  def test
    puts "42"
  end
  def self.debug(*methods)
    methods.each{|method| 
      name = method.id2name
      org = "_debug_"+name
      module_eval <<MSG
      alias #{org} #{name}
      def #{name}(*a,&b)
        puts("before")
        #{org}(*a,&b) 
        puts("after") 
      end
      private :#{org}
MSG
    }
  end
  debug :test
end

Test.new.test
server>