Today I realized that I'm need of a DB persistence layer for Ruby, making it easy to map a DB table to an object. I know that something like this already exists, it's the ActiveRecord part of
Ruby on Rails web application framework. But... I don't want to restrict myself to web applications, and I don't want to rip out the ActiveRecord part out of RoR, I want to write it on my own. Fortunately, Ruby makes that pretty easy, as it is completely dynamic, and thus makes it possible to "define" new methods on-the-fly (actually, it works a bit different internally, but you won't be able to see any difference from outside -- that's how encapsulation should be
).
I did some research on the topic of good DB persistence layer design, and found a nice
page on exactly that topic. I won't implement all the optional parts of the whole concept, and Ruby simplifies a few things so the class diagram will be a bit simpler for my system, as the paper is actually a bit Java-specific.
What will definitely miss is the automatic "resolution" of 1:1 and 1:n relations as found in RoR, but so far the design is so simple yet flexible that (I think) it will also be usable for stuff like LDAP. So far, not much code exists, but I will keep you up-to-date.
On an interesting side note, an (ex-)colleague was poached for writing a simple and fast persistence layer for Java. But I don't even think about leaving my current employer!