From: Anders Bengtsson Date: 2001-04-17T20:07:12+09:00 Subject: [ruby-talk:13740] Wrapping objects Hi everyone, I'm developing a simple persistence mechanism for Ruby using wrappers (or proxies) around objects. Is it possible somehow to override the constructors of a class so that it will always return an instance of another class? Something like this: class PersistentWrapper def initialize(persistable) #... end end module Persistable #... end class Foo include Persistable #... end Foo.new # ==> an instance of PersistentWrapper .. that is, every class that has Persistable mixed in should return wrapped instances, instead of the instances directly. I've looked at the various callback methods in Module, but I haven't figured out any way to do this yet. Does anyone have any ideas on how to do this? thanks, /Anders ===== __________________________________________________ Anders Bengtsson ndrsbngtssn@yahoo.se Stockholm, Sweden _____________________________________________________ Do You Yahoo!? Ditt_namn@yahoo.se - skaffa en gratis mailadress p� http://mail.yahoo.se