lib/dry/effects/extensions/system.rb in dry-effects-0.2.0 vs lib/dry/effects/extensions/system.rb in dry-effects-0.3.0
- old
+ new
@@ -1,27 +1,27 @@
# frozen_string_literal: true
-require "dry/system/container"
+require "dry/system"
Dry::Effects.load_extensions(:auto_inject)
module Dry
module Effects
module System
class AutoRegistrar < ::Dry::System::AutoRegistrar
# Always memoize and freeze registered components
def call(component_dir)
- components(component_dir).each do |component|
+ component_dir.each_component do |component|
next unless register_component?(component)
container.register(component.key, memoize: true) { component.instance.freeze }
end
end
end
class Container < ::Dry::System::Container
- config.auto_registrar = AutoRegistrar
+ setting :auto_registrar, default: AutoRegistrar
def self.injector(effects: true, **kwargs)
if effects
Dry::Effects.AutoInject(**kwargs)
else
@@ -33,10 +33,10 @@
return self if finalized?
super
# Force all components to load
- each_key { |key| resolve(key) }
+ each_key { resolve(_1) }
self
end
end
end
end