On Sep 5, 2006, at 8:05 PM, jdonnell wrote: > is there a way for an object to tell you where it was created a la > stacktraces? > > I tried to hack it in myself, but it's really slowwwwwww. Here was my > hack attempt. I also wanted each object to tell me the time it was > created which works fine. > > class Object > attr_accessor :mp_created_at > attr_accessor :origin_trace > end > Is this close enough? class Class alias rb_new new def new(*args, &block) stack = caller obj = rb_new(*args, &block) obj.origin_trace = stack obj.mp_created_at = Time.now unless obj.frozen? obj end end