From: Robert Dober Date: 2008-04-20T23:31:09+09:00 Subject: Re: Executing code in a variable On Sun, Apr 20, 2008 at 3:53 PM, David A. Black wrote: As David I am not sure that instance_eval is safer than eval. As the following example shows a save eval can be done by deleting all dangerous methods before evalling: module Kernel class << self methods.each do |m| next if /^__/ === m Object::send :remove_method, m end end instance_methods.each do |m| next if /^__/ === m Object::send :remove_method, m remove_method m end end eval % Now this might not often be very useful though as we do not have a sandbox or to put it better, it is much work to get out of the sandbox again as we have to redefine all methods again (well I did not safe them in the first place here). Furthermore my sandbox is empty!!! Is there an easy way to do this? Cheers Robert -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein