From: Keith Rarick Date: 2007-08-03T15:29:06+09:00 Subject: method_added hook and class methods Hello all, I am puzzled at some behavior I recently observed in ruby. I searched the archives and google and didn't see an answer, so I am asking here: First I want to observe when instance methods are defined in a class, so I do this: class C class << self def method_added(name) puts 'added ' + name.to_s end end def an_instance_method end end As I expect, this program prints "added an_instance_method". Now I want to observe when class methods are defined. My understanding of ruby says that "class methods" are really just instance methods of the metaclass. So I do this: class C class << self class << self def method_added(name) puts 'added ' + name.to_s end end def a_class_method end end end I expect this program to print "added a_class_method", but it produces no output. Am I misunderstanding something or is this a bug? Is there some other way to observe when class methods are defined? Any help would be very much appreciated. kr -- Posted via http://www.ruby-forum.com/.