lib/hanami/configuration.rb in hanami-1.1.1 vs lib/hanami/configuration.rb in hanami-1.2.0.beta1
- old
+ new
@@ -1,26 +1,16 @@
require 'concurrent'
-require 'delegate'
require 'hanami/application'
require 'hanami/utils/class'
require 'hanami/utils/string'
module Hanami
# @api private
class Configuration
- # @api private
- class App < SimpleDelegator
- # @api private
- attr_reader :path_prefix
+ require "hanami/configuration/app"
+ require "hanami/configuration/middleware"
- # @api private
- def initialize(app, path_prefix)
- super(app)
- @path_prefix = path_prefix
- end
- end
-
# @api private
def initialize(&blk)
@settings = Concurrent::Map.new
instance_eval(&blk)
end
@@ -103,9 +93,39 @@
# @since 0.9.0
# @api private
def mounted
settings.fetch_or_store(:mounted, {})
+ end
+
+ # @since x.x.x
+ def middleware
+ settings.fetch_or_store(:middleware, Configuration::Middleware.new)
+ end
+
+ # Setup Early Hints feature
+ #
+ # @since x.x.x
+ #
+ # @example Enable for all the environments
+ # # config/environment.rb
+ # Hanami.configure do
+ # early_hints true
+ # end
+ #
+ # @example Enable only for production
+ # # config/environment.rb
+ # Hanami.configure do
+ # environment :production do
+ # early_hints true
+ # end
+ # end
+ def early_hints(value = nil)
+ if value.nil?
+ settings.fetch(:early_hints, false)
+ else
+ settings[:early_hints] = value
+ end
end
# @since 0.9.0
# @api private
def apps