lib/hanami/configuration.rb in hanami-2.0.0.beta2 vs lib/hanami/configuration.rb in hanami-2.0.0.beta3
- old
+ new
@@ -7,11 +7,10 @@
require "dry/inflector"
require "pathname"
require_relative "constants"
require_relative "configuration/logger"
-require_relative "configuration/router"
require_relative "configuration/sessions"
require_relative "settings/env_store"
require_relative "slice/routing/middleware/stack"
module Hanami
@@ -104,24 +103,26 @@
self.root = Dir.pwd
load_from_env
config.logger = Configuration::Logger.new(env: env, app_name: app_name)
- @assets = load_dependent_config("hanami/assets/app_configuration") {
- Hanami::Assets::AppConfiguration.new
- }
+ # TODO: Make assets configuration dependent
+ require "hanami/assets/app_configuration"
+ @assets = Hanami::Assets::AppConfiguration.new
- @actions = load_dependent_config("hanami/action") {
+ @actions = load_dependent_config("hanami-controller") {
require_relative "configuration/actions"
Actions.new
}
- @middleware = Slice::Routing::Middleware::Stack.new
+ @router = load_dependent_config("hanami-router") {
+ require_relative "configuration/router"
+ @middleware = Slice::Routing::Middleware::Stack.new
+ Router.new(self)
+ }
- @router = Router.new(self)
-
- @views = load_dependent_config("hanami/view") {
+ @views = load_dependent_config("hanami-view") {
require_relative "configuration/views"
Views.new
}
yield self if block_given?
@@ -207,17 +208,16 @@
instance_eval(&block)
end
end
# @api private
- def load_dependent_config(require_path)
- require require_path
- yield
- rescue LoadError => e
- raise e unless e.path == require_path
-
- require_relative "configuration/null_configuration"
- NullConfiguration.new
+ def load_dependent_config(gem_name)
+ if Hanami.bundled?(gem_name)
+ yield
+ else
+ require_relative "configuration/null_configuration"
+ NullConfiguration.new
+ end
end
def method_missing(name, *args, &block)
if config.respond_to?(name)
config.public_send(name, *args, &block)