From: "Ara.T.Howard" Date: 2004-07-01T01:02:52+09:00 Subject: Re: Opinions on library interface design? On Wed, 30 Jun 2004, Kirk Haines wrote: > Kansas, if you are unaware, is an object-relational mapping library. Result > sets from queries are returned as hash-like objects. However, be object > knows where it came from, and updating the object causes the underlying > database data to be updated transparently. This lets one manipulate the > data without worrying about writing SQL. i was unaware - sounds super cool - i'll check it out today. > So....what is a nice, elegant way to tell select() that I want the result > set back as hashes, or arrays (or arrayfields), or structs, or whatever, > instead of the default db coupled objects? i like the idea of NOT using 'select' since, in essence these object have not been 'selected' as our working set - we would only be looking at them. to me that suggests a completely new method name, something like def browse criteria, as = Hash cb = block_given? accum = [] query(criteria) do |intermediate| res = case as when Hash intermediate.to_h when Array intermediate.to_a when Struct intermediate.to_su else as.new intermediate end cb ? yield res : accum << res end cb ? self : accum end which provide some canned types to be returns and would provide user defineable types to be returned (case - else). thoughts... -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 ===============================================================================