GDBM plus classes other than String

Hi –

As an offshoot of some playing around with ActiveModel (part of Rails
3) and adding non-relational database backends to Rails, I’ve spawned
a little project called GDBMP, which lets you use non-string keys and
values in GDBM files.

I literally don’t remember why I chose to add “P”.

Anyway, it lets you do things like:

g =“/tmp/myfile.gdbmp”)
g[123] = :abc
g[:def] = 12.3

etc. The way it works is to store class names along with keys and
values, and then perform conversions on the way out.

It’s pretty much hard-wired to a handful of classes, and pretty
simple-minded about the conversions, though you can also constrain
keys to have their values be of certain classes:

g.constrain_key(:year, Fixnum)
g[:year] = “1999”
g[:year] # 1999 (the integer)

You can find it on github:

GitHub - dblack/gdbmp: GDBMP -- a subclass of GDBM allowing for keys and values of classes other than String