accessing binding in eval with $SAFE=4

N

ngrandy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top