From: El Gato Date: 2007-02-27T01:43:09+09:00 Subject: Re: Subclassing Array Ilan Berci wrote: > El Gato wrote: >> I'm sure I'm just being an idiot here... my mind is a little foggy this >> morning, but I'm having a hard time understanding how to accomplish >> this. I've written a class (I'll just put some snippets in for >> understanding) in which I'd like to be able to use the following >> behavior: >> > > El Gato, > > My suggestion is to take a good look at Ruby's incredibly powerfull use > of delegates > http://www.ruby-doc.org/stdlib/libdoc/delegate/rdoc/index.html > (documentation provided by James Earl Gray II) > > Secondly, there is a great book entitled "Ruby Recipes", which discusses > your question in great detail and I higly recommend that you pick it > up.. > > Hope this helps and this is only a suggestion as there exists 100 ways > to do what you are asking.. :) > > ilan I'm not sure if I'm missing something, but it appears that calling map() on a DelegateClass still returns an Array object. I guess I would need map() and friends to return an InventoryReport class (i.e., Array doesn't have a save method, whereas InventoryReport does, so calling report.query.map {...}.save "/tmp/filename.xls" fails) -- Posted via http://www.ruby-forum.com/.