I'm writing objects that maintain a connection to a database and all
methods and accessors actually work on the database. Now I would like
my objects to close the database connection on destruction. Since
ruby uses garbage collection there is no explicit destructor. Are there
any hooks that could be used for this?

A second destructor-related problem arises when I tell my object to
delete it's data from the database. The object is no longer useful
and I would like my object to destroy itself. ("This object will
self-destruct in 10 seconds")

Any hits on how to accomplish this?

Cheers
Martin