From: "Iñaki Baz Castillo" Date: 2008-04-13T05:41:37+09:00 Subject: Re: How to duplicate a object changing the class without attributes memory copy 2008/4/12, Joel VanderWerf : > Why do you need a From class that is distinct from Header? Because in an initial parsing I just get a headers array, whiotu inspecting each of them. Later, if I need, I look for some specific headers (From, To...) and need to add some methods to them. > Depending on the > reason, it might work to make From a module: > > module From > # special From methods here > end > > headers.each do |h| > if h.name == "From" > h.extend From > end > # or maybe something like: > # h.extend const_get(h.name) > end Thanks, this is great! I didn't know "extend" method. -- Iñaki Baz Castillo