[Nitro] Og [patch]: Rename write_attr_<class> to serialize_attr_<class>
Mark Van De Vyver
mvyver at gmail.com
Fri Oct 5 07:30:16 EDT 2007
Some detail...
On 10/5/07, Mark Van De Vyver <mvyver at gmail.com> wrote:
> On 10/5/07, George Moschovitis <george.moschovitis at gmail.com> wrote:
> > I kind of like
> >
> > read_attr
> > write_attr
The method
SqlStore#read_attr
currently calls:
self.class.parse_<klass>(res[col + offset])
while
SqlStore#write_attr
currently calls:
write_attr_<klass>(value)
None of these actualy read or write anything - in fact I ignored even
looking at them for a long time since I wasn't at the point of
reading/writing data... silly me :)
The RDoc is most accurate:
They serliaze/deserialize instances of Og objects. Later on some
other method reads/writes this data - for sql stores the closest
methods to doing this are SqlStore#exec and SqlStore#query - even then
I'd argue it's still misleading naming to call them read/write.
anyway it is irrelevant right.
Now SqlStore#quote (and hence <vendor>Adapter) deals with arrays, but
re-implements all that is done in write_attr.
This opens the door for inconsistencies.
I'm heading towards closing that door, but I'll close it first in the
DbiAdapter, and then only when spec's are in place.
I'd guess a reason for this is that someone baulked at using
#write_attr in the quote loop, as in the following (untested):
module SqlUtils
def quote(vals)
vals = [vals] unless vals.is_a?(Array)
quoted = vals.inject("") do |s, val|
s += write_attr + ','
end
quoted.chop!
vals.size > 1 ? "(#{quoted})" : quoted
end
end
But essentially that is 99% of what is happening in SqlUtils#quote.
The non DbiAdapter spec's will flow as I make them....
> I haven't touch write_attr - yet :)
and won't until there is a spec in place.
HTH
Mark
> if you're still not convinced let me know I'll try and explain why.
> Mark
>
>
> > (notice the symmetry)
> >
> > -g.
> >
> >
> > On 10/5/07, Mark Van De Vyver < mvyver at gmail.com> wrote:
> > >
> > > These changes should have no effect at the users level?
> > >
> > > * Rename write_attr_<class> to serialize_attr_<class>
> > > These names properly reflect what is happening. Renaming is also a
> > > precursor to some changes that 1) DRY out the serialization that
> > > occurs in Og, 2) Should permit Og's type mapping to be extensible
> > > (without touching the code).
> > >
> > > _______________________________________________
> > > Nitro-general mailing list
> > > Nitro-general at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/nitro-general
> > >
> > >
> >
> >
> >
> > --
> > http://gmosx.me.gr
> > http://phidz.com
> > http://blog.gmosx.com
> > http://cull.gr
> > http://www.joy.gr
> > http://nitroproject.org
>
More information about the Nitro-general
mailing list