lib/hanami.rb in hanami-2.0.0.alpha1 vs lib/hanami.rb in hanami-2.0.0.alpha2

- old
+ new

@@ -5,29 +5,31 @@ # @since 0.1.0 # # @see http://hanamirb.org module Hanami require "hanami/version" - require "hanami/frameworks" - require "hanami/container" require "hanami/application" @_mutex = Mutex.new def self.application @_mutex.synchronize do - raise "Hanami application not configured" unless defined?(@_application) + raise "Hanami.application not configured" unless defined?(@_application) @_application end end - def self.application=(app) + def self.application? + defined?(@_application) + end + + def self.application=(klass) @_mutex.synchronize do - raise "Hanami application already configured" if defined?(@_application) + raise "Hanami.application already configured" if defined?(@_application) - @_application = app unless app.name.nil? + @_application = klass unless klass.name.nil? end end def self.app @_mutex.synchronize do @@ -43,34 +45,33 @@ @_app = app end end - def self.root - Container.root - end - def self.env (ENV["HANAMI_ENV"] || "development").to_sym end def self.env?(*names) names.map(&:to_sym).include?(env) end def self.logger - Container[:logger] + application[:logger] end - def self.boot - @_mutex.synchronize do - raise "Hanami application already booted" if defined?(@_booted) + def self.init + application.init + end - @_booted = true - end + def self.boot(web: true) + if defined?(@_app) + @_app + else + application.boot - Container.finalize! - self.app = application.new + @_app = application.new if web + end end def self.bundler_groups [:plugins] end