class Dry::System::AutoRegistrar
Default auto-registration implementation
This is currently configured by default for every System::Container
. Auto-registrar objects are responsible for loading files from configured auto-register paths and registering components automatically within the container.
@api private
Attributes
container[R]
Public Class Methods
new(container)
click to toggle source
# File lib/dry/system/auto_registrar.rb, line 19 def initialize(container) @container = container end
Public Instance Methods
call(component_dir)
click to toggle source
@api private
# File lib/dry/system/auto_registrar.rb, line 31 def call(component_dir) component_dir.each_component do |component| next unless register_component?(component) container.register(component.key, memoize: component.memoize?) { component.instance } end end
finalize!()
click to toggle source
@api private
# File lib/dry/system/auto_registrar.rb, line 24 def finalize! container.component_dirs.each do |component_dir| call(component_dir) if component_dir.auto_register? end end
Private Instance Methods
register_component?(component)
click to toggle source
# File lib/dry/system/auto_registrar.rb, line 41 def register_component?(component) !container.registered?(component.key) && component.auto_register? end