def foo 'bar' end module M def foo 'baz' end end puts "should be 'bar': #{foo}" self.dup.instance_eval do extend(M) puts "should be 'baz': #{foo}" end puts "should be 'bar': #{foo}"
Garry Dolley worked out some interesting Ruby-fu to create a temporary execution context on the fly using self.dup.instance_eval. Any other tricks we could use this for?

Comments
Chris ·
That's real hot. Real hot.