From: transfire@... Date: 2006-07-10T22:44:32+09:00 Subject: Re: instance_exec Duh! I'm sitting here screwing with this and the answer's sitting one directory over.. with only a minor modification (I added recv=nil) I introduce you to Facets' Proc#to_method: #-- # Credit for #to_method goes to Forian Gross (flgr). #-- require 'thread' class Proc MethodMutexes = Hash.new do |hash, key| hash[key] = Mutex.new end # Creates a local method based on a Proc. def to_method(name=nil, recv=nil) name ||= "!to_method_temp#{self.object_id}" recv ||= eval("self", self) klass = recv.class MethodMutexes[klass => name].synchronize do begin klass.send(:define_method, name, &self) return recv.method(name) ensure klass.send(:remove_method, name) if not name end end end end Then instance_exec is simply: module Kernel def instance_exec(*args, &block) block.to_method(nil,self).call(*args) end end Proof is in the pudding. Facets' really does pay off! T.