Helpful - yes, in finding out that using eval might not be what I'm
after. I thought, at first, that a binding housed the entirety of a
running ruby process' context.
Sort of. It includes the context of wherever the binding was created.
If you call binding in the top level of your script, you'll get all of
that context that you can execute inside of.
I'm wanting to run ruby snippets like the below:
require 'rake'
default = task :default do
# do stuff
end
default.invoke
That's exactly what I'm doing 
But for my problem, I might be better off using Kernel::system, and
invoking ruby in an external process, even though I'd really like my
little code-snippet to be able to access, for instance, the Logger
I've set up in my queue-system.
You can pretty easily inject variables into your binding. As I looked
at my code, I realized that I actually am not using the BindingFactory
idea (it was a prototype that I ended up not sticking with).
Instead, I have a Workspace class. It's got a method called #set_value
that takes a name and value and sets an instance variable and adds an
attr_reader inside the workspace's eigenclass.
Then, the tasks that I've got (I call them Command in my code) know how
to execute themselves inside a workspace, so I can just say
command.execute( workspace )
and it calls the proc inside that binding.
I'm working on getting my code released (gotta get the company to
agree), and until then I can't show too much, but I'm happy to talk
about it more if it sounds similar enough to what you're doing to help.
Ben
···
On Fri, Feb 23, 2007, Hans Sjunnesson wrote: