Instance_eval and Proc objects


#1

Hi All,

Got a bit of a Ruby question for you.

If I have a function that makes a proc object like this:

def select(selector, &proc)
el = Element.new
el.instance_eval proc
end

select("#thing") do
hide
end

Wat I want to do is evaluate the Proc in the context of el but this
doesn’t work because instance_eval accepts a string or a block and not
a Proc object. I sense Im barking up the wrong tree here entirely but
Im pretty new to this Ruby game so forgive me.

Any suggestions?

Cheers,

Dan


#2

It’s okay, I worked it out myself:

el.instance_eval &proc

Just like with starred method arguments…

On 2/10/06, Dan W. removed_email_address@domain.invalid wrote:

Cheers,

Dan


Dan W.
http://www.danwebb.net