From: "Ara.T.Howard" Date: 2004-07-02T08:52:49+09:00 Subject: [OT] Re: [ANN] SQLite-Ruby 1.2.0 On Fri, 2 Jul 2004, Sean O'Dell wrote: > On Thursday 01 July 2004 15:03, Ara.T.Howard wrote: >> On Fri, 2 Jul 2004, Kirk Haines wrote: >>> I was going to suggest that the hash methods be added. I don't see a >>> downside to doing that. >> >> some of them are out, like each, since the impl for Array and Hash are >> different, but some methods like > > Isn't it a unique object now? For some reason, I thought you made ArrayFields > its own class. If you did that, you could add each because ArrayFields is a > hash interface to arrays; it's hash-like. > > Sean O'Dell ArrayFields is a Module used to extend only those Array instances that use the #fields= method. the Array class itself is never modified. FieldedArray is a class which wraps an array and which also includes ArrayFields. by defining method_missing to use it's wrapped array it can leveage the ArrayFields module w/o extend the actual array object. summary: - class Array never has anything added to it other than #fields= - if, and only if, #fields= is called then that instance will auto-extend it's singleton class to have the methods of ArrayFields - FieldedArray behaves just like an Array whose singleton class has been extended, but w/o actually extending it. this is accompished by both extending the FieldedArray object with ArrayFields AND delgating missing methods (in this case all the calls to super in ArrayFields) to this array. cheers. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================