lib/hanami/model.rb in hanami-model-1.0.0.beta2 vs lib/hanami/model.rb in hanami-model-1.0.0.beta3

- old
+ new

@@ -1,10 +1,13 @@ require 'rom' require 'concurrent' require 'hanami/entity' require 'hanami/repository' +# Hanami +# +# @since 0.1.0 module Hanami # Hanami persistence # # @since 0.1.0 module Model @@ -73,8 +76,33 @@ # @since 0.1.0 def self.load!(&blk) @container = configuration.load!(repositories, &blk) @loaded = true + end + + # Disconnect from the database + # + # This is useful for reboot applications in production and to ensure that + # the framework prunes stale connections. + # + # @since x.x.x + # + # @example With Full Stack Hanami Project + # # config/puma.rb + # # ... + # on_worker_boot do + # Hanami.boot + # end + # + # @example With Standalone Hanami::Model + # # config/puma.rb + # # ... + # on_worker_boot do + # Hanami::Model.disconnect + # Hanami::Model.load! + # end + def self.disconnect + configuration.connection && configuration.connection.disconnect end end end