Add docs for DB::Database#setup_connection (#139)

This commit is contained in:
Jamie Gaskins 2020-10-27 11:55:06 -04:00 committed by GitHub
parent bd45602864
commit eaddae7d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -61,6 +61,15 @@ module DB
}
end
# Run the specified block every time a new connection is established, yielding the new connection
# to the block.
#
# ```
# db = DB.open(DB_URL)
# db.setup_connection do |connection|
# connection.exec "SET TIME ZONE 'America/New_York'"
# end
# ```
def setup_connection(&proc : Connection -> Nil)
@setup_connection = proc
@pool.each_resource do |conn|