From: Brian Candler Date: 2012-02-06T07:03:59+09:00 Subject: Re: Hooking a function to run in IRB context (but only in IRB context)? Marc Heiler wrote in post #1044134: > Now I want to hook up a specific class. Let's call it > > class Foo > end > > This class should intercept BEFORE NameError happens. It should then > check that input, like: > > Foo.new(input) > Foo.new('pj') > > And it will decide against an internal list: > > - When the input was found in the internal list, an action is done, > and no error is reported. > > - When the input was NOT found, a NameError is triggered just as it > currently is. >> def method_missing(meth,*args,&blk) >> puts "You tried to run '#{meth}'" >> end => nil >> pj You tried to run 'pj' => nil >> -- Posted via http://www.ruby-forum.com/.