From: Paul Brannan Date: 2002-04-19T04:17:17+09:00 Subject: Re: Object#send with $SAFE >= 1 On Fri, Apr 19, 2002 at 04:10:42AM +0900, Jason Voegele wrote: > I'm writing a web application for which I need to call methods dynamically > (i.e. the name of the method is determined at run time). The $SAFE level > for the server I'm using is set to 1. > > Unfortunately, since #send uses #eval, it's considered an unsafe operation > and cannot be used with $SAFE >= 1. I've also tried using Object#method to > retrieve the method by name and call it indirectly, but that is also > considered unsafe and disallowed. > > Is there any way to call a method by name with $SAFE >= 1? AFAIK, #send does not use #eval. It also works with $SAFE == 1: irb(main):001:0> $SAFE = 1 1 irb(main):002:0> class Foo; def foo; puts "foo!"; end; end nil irb(main):003:0> f = Foo.new # irb(main):004:0> f.send(:foo) foo! nil If you are getting a SecurityError, it is probably coming from somewhere else. Paul