From: Dave Thomas Date: 2000-01-02T23:19:28-06:00 Subject: [ruby-talk:01024] Tracing attributes I've been playing with a tracing module. One of the things it does is define a tracing version of 'attr' class Module def trace_attr(id, writable=false) name = id.id2name class_eval %{ def #{name} trace "Accessing #{name} (", @#{name}, ")\n" @#{name} end } if (writable) class_eval %{ def #{name}=(val) trace "#{name} (was ", @#{name}, ") => ", val, "\n" @#{name} = val end } end end end So you can log accesses to an attribute by defining it using 'trace_attr': class Test trace_attr :fred, true //... end Two questions: 1. Is this a reasonable thing to do? Is it OK to mess around with methods in Module? 2. Is this an acceptable implementation? Thanks Dave