From: Erik Veenstra Date: 2006-07-10T19:12:49+09:00 Subject: Re: instance_exec > The example you gave does work with my implementation too: > > RUBY_VERSION # => "1.8.5" > RUBY_RELEASE_DATE # => "2006-06-24" > class Object > module InstanceExecHelper; end > include InstanceExecHelper > def instance_exec(*args, &block) > mname = "__instance_exec_#{Thread.current.object_id.abs}_#{object_id.abs}" If instance_exec is called recursively, like in the example, the mname for the outer method is reused for defining the inner method. This isn't really a problem, but conceptually not very "clean"... Did it work "by accident", or did you really intent to reuse the name? ;] > InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil This "rescue nil" might have been an indication of this "bad design"... ;] I wonder, why did you use a module for the context, instead of the good old meta class? gegroet, Erik V. - http://www.erikveen.dds.nl/