Assuming I have the following proc:
a = Proc.new do
puts "start"
yield
puts "end"
end
It is also assumed that I pass to aanother method, which subsequently calls instance_evalin another class with this block, how can I pass the block to the end of this method, which is obtained in a.
For instance:
def do_something(a,&b)
AnotherClass.instance_eval(&a)
end
a = Proc.new do
puts "start"
yield
puts "end"
end
do_something(a) do
puts "this block is b!"
end
The output should, of course, be:
start
this block is b!
end
How to transfer the secondary unit to in instance_eval?
I need something like this at the heart of the Ruby template system I'm working on.
source
share