Instance_eva()l-ing a proc with parameters

Logan Capaldo wrote:


On Tue, Oct 03, 2006 at 01:35:48AM +0900, Gennady Bystritsky wrote:

Dear friends,

I need to evaluate a proc within an instance context and would like
to pass it a parameter. The only straight forward way I found is to
use instance_eval(), however it does not allow to pass parameters to
a proc, only the instance itself is passed as a single parameter:

Google for instance_exec, there are various and sundry
implementations, including one built into rails. has various
implementations and their respective strengths and weaknesses. Or you
just use ruby
1.9 where it's part of the core.

Thanks a lot, Logan. That's exactly what I need and what I have missed
completely here on the list when the discussion first came up.

It looks like I am better off sticking to my define_method() custom
solution for now, as instance_exec() uses the same approach anyway.

Thanks again,