From: Ehsanul Hoque Date: 2009-09-19T09:19:28+09:00 Subject: Re: How to derive from DateTime? --_55cf36fb-8a2f-422e-b421-59ca8aeed4cb_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > It looks to me that this is a case where you might be better served by us= ing > composition and delegation rather than inheritance: instead of an Event > being a specialized DateTime=2C it would have a DateTime instance as an > instance variable and delegate certain methods (e.g.=2C year=2C etc.) to = that > instance variable. >=20 I agree with Christopher here. What you want is a proxy class. Here's a way= you might implement it: class Event def self.new( *args ) class << datetime =3D DateTime.new(*args) def sweet "what a sweet method" end end datetime end end You could also try this way: class Event instance_methods.each { |m| undef_method m unless m =3D~ /(^__|^send$|^= object_id$)/ } def initialize(*args) @date_time =3D DateTime.new(*args) end def method_missing(name=2C *args=2C &block) @date_time.send(name=2C *args=2C &block) end end I'm sure you can figure out what's happening here=2C and how to merge it wi= th your own code. - Ehsan =0A= _________________________________________________________________=0A= Bing=99 brings you maps=2C menus=2C and reviews organized in one place. = Try it now.=0A= http://www.bing.com/search?q=3Drestaurants&form=3DMLOGEN&publ=3DWLHMTAG&cre= a=3DTEXT_MLOGEN_Core_tagline_local_1x1= --_55cf36fb-8a2f-422e-b421-59ca8aeed4cb_--