[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

accessing binding in eval with $SAFE=4

Nick Grandy

2/15/2008 5:50:00 AM

hi all,
can anyone explain why this doesn't work?

class MyBinding
def my_test
"success!"
end
end

b = MyBinding.new.instance_eval{binding}

thread = Thread.start do
$SAFE = 4
cmd = 'my_test'
result = eval(cmd, b)
end
p thread.value

i know i can't modify the binding object in $SAFE=4, but i thought i
could access it at least. what is an alternate approach? i am trying
to execute code in a safe(ish) way within a context of my choice.
thanks,
nick