lib/dry/system/container.rb in dry-system-0.25.0 vs lib/dry/system/container.rb in dry-system-0.26.0
- old
+ new
@@ -84,12 +84,11 @@
setting :auto_registrar, default: Dry::System::AutoRegistrar
setting :manifest_registrar, default: Dry::System::ManifestRegistrar
setting :provider_registrar, default: Dry::System::ProviderRegistrar
setting :importer, default: Dry::System::Importer
- # We presume "." as key namespace separator. This is not intended to be
- # user-configurable.
+ # Expect "." as key namespace separator. This is not intended to be user-configurable.
config.namespace_separator = KEY_SEPARATOR
class << self
extend Dry::Core::Deprecations["Dry::System::Container"]
@@ -125,18 +124,11 @@
# @see after
#
# @api public
def configure(finalize_config: true, &block)
super(&block)
-
- unless configured?
- hooks[:after_configure].each { |hook| instance_eval(&hook) }
- config.finalize! if finalize_config
- @__configured__ = true
- end
-
- self
+ configured!(finalize_config: finalize_config)
end
# Marks the container as configured, runs the after-`configured` hooks, then
# finalizes (freezes) the {config}.
#
@@ -154,14 +146,21 @@
# @api public
def configured!(finalize_config: true)
return self if configured?
hooks[:after_configure].each { |hook| instance_eval(&hook) }
- config.finalize! if finalize_config
+
+ _configurable_finalize! if finalize_config
+
@__configured__ = true
self
end
+
+ # Finalizes the config for this container
+ #
+ # @api private
+ alias_method :_configurable_finalize!, :finalize!
def configured?
@__configured__.equal?(true)
end