问题
I have a test that is creating and destroying a number of databases in postgresql. In order to be able to drop a database I need to tell DataMapper to disconnect. I can't seem to find any documentation on how to do that.
There is a close_connection method on DataMapper::Adapters::PostgresAdapter but it is protected and requires a connection object that I can't seem to get.
Is this even possible?
回答1:
DataObjects::Pooling.pools.each {|pool| pool.dispose}
seems to work as long as you have only one connection open at a time.
来源:https://stackoverflow.com/questions/4262135/force-datamapper-to-disconnect-from-postgresql