eval / current binding

R

redroofgreentree

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hey,

So I've looked at module_eval, class_eval, and Kernel#eval

and I'm pretty sure that what I want to do is to do Kernel#eval("blah ...
some code", global_environment)

where by global_environment I mean the global_context or the
global_binding

The problem now ... is that I don't know how to access this global
environment / global context / global binding ... is there a function that I
can call that will

(1) get me the global binding / global env / global context or
(2) a function that I can call that will get me the current binding / env
/ context

Thanks,
(when replying please cc the list and me)
 
M

MonkeeSage

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hey,

So I've looked at module_eval, class_eval, and Kernel#eval

and I'm pretty sure that what I want to do is to do Kernel#eval("blah ...
some code", global_environment)

where by global_environment I mean the global_context or the
global_binding

The problem now ... is that I don't know how to access this global
environment / global context / global binding ... is there a function that I
can call that will

(1) get me the global binding / global env / global context or
(2) a function that I can call that will get me the current binding / env
/ context

Thanks,
(when replying please cc the list and me)

The TOPLEVEL_BINDING constant...but the standard disclaimer is don't
use eval (depends on what you're doing though). It is generally not
safe unless you have 100% control over the input, because it can do
everything ruby can (i.e., eval doesn't run in any kind of sandbox),
so in an untrusted context, it's dangerous.

Regards,
Jordan
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top