From: Patrick Hurley Date: 2005-06-20T02:26:19+09:00 Subject: Wrapped load I am building an internal batch processor -- I am not worried about malicious code (rm -rf *) type stuff, but I would like to be able to run most any ruby code without worrying about side effects in the batch processor, so a wrapped load sounded perfect. I wanted to isolate changes to existing classes, so I put together this ever useful program (foo.rb): module Kernel alias old_puts puts def puts(*args) args.each do |stuff| old_puts "Fancy #{stuff}" end end def boo(x) puts x ** 2 end end puts "Wow" ------------------------------ and then this even more impressive test body ------ puts "One" load('foo.rb', true) puts "Two" load('foo.rb', false) puts "Three" ------------------------------------------------------------------------------------------------------- Which outputs: One Wow Two Fancy Wow Fancy Three What I really wanted was: One Fancy Wow (how do I get this?) Two Fancy Wow Fancy Three As it stands the wrapped code does not execute the same -- is there a way to get it to, without having those effects leak into the loading application? Thanks Patrick