Check this following code, taken from Jim Weirich's OSCON slides about the "10 Things Every Java Programmer Should Know About Ruby".
class VCR def initialize @messages = [] end def method_missing(method, *args, &block) @messages << [method, args, block] end def play_back_to(obj) @messages.each do |method, args, block| obj.send(method, *args, &block) end endend
Nice stuff, it records all of the messages sent to an object, and can then replay them back on any other object. :)
Also, while on the subject of Ruby - there's a really interesting video available at the Rails website, that demonstrates the creation of a weblog in 15 minutes, show how some tricky code generation and dynamic site reloading works together to build a website very quickly. Very interesting stuff.
Posted by crafterm at August 9, 2005 12:54 PM | TrackBack