I'm playing with the RubyLanguage and I'm trying to override eval with my own eval. The PseudoCode is like this:
def eval( params ) doSomething old_eval( params ) doSomethingElse endHow can I call the old eval from the new-one?
solution:
alias :oldEval :eval def eval( code ) puts "antes eval" oldEval( code ) puts "despues eval" end $a = "Hola mundo" eval "puts $a"
Eval is a method of the Kernel. You can access it with 'Kernel.eval'.
def eval( params ) puts 'before eval' Kernel.eval( params ) puts 'after eval' endIn irb you can see a list of all the Kernel methods by invoking 'Kernel.methods.sort'.