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

- old
+ new

@@ -11,11 +11,11 @@ # Require the entire project # # @since 0.9.0 # @api private register 'all' do - requires 'logger', 'mailer', 'code', 'model', 'apps', 'finalizers' + requires 'logger', 'code', 'mailer', 'model', 'apps', 'finalizers' resolve { true } end # Setup project's logger @@ -48,15 +48,16 @@ !!(defined?(Shotgun) && # rubocop:disable Style/DoubleNegation Components['environment'].code_reloading?) end end + # @api private register 'code' do run do directory = Hanami.root.join('lib') - if Hanami.code_reloading? + if Components['environment'].code_reloading? Utils.reload!(directory) else Utils.require!(directory) end end @@ -75,10 +76,14 @@ # Hanami::Components.resolve('model') # Hanami::Components['model'] # => nil register 'model' do requires 'logger', 'model.configuration', 'model.sql' + prepare do + Hanami::Model.disconnect if Components['model.configuration'] + end + resolve do if Components['model.configuration'] Hanami::Model.load! Hanami::Model.configuration.logger = Components['logger'] true @@ -175,12 +180,14 @@ require 'hanami/mailer' require 'hanami/mailer/glue' end resolve do |configuration| - Hanami::Mailer.configuration = Hanami::Mailer::Configuration.new if Hanami.code_reloading? - Hanami::Mailer.configure(&configuration.mailer) - Hanami::Mailer.configuration + unless configuration.mailer.nil? + Hanami::Mailer.configuration = Hanami::Mailer::Configuration.new if Hanami.code_reloading? + Hanami::Mailer.configure(&configuration.mailer) + Hanami::Mailer.configuration + end end end # Tries to load hanami-mailer #