Class: Dry::System::AutoRegistrar Private
- Inherits:
-
Object
- Object
- Dry::System::AutoRegistrar
- Defined in:
- lib/dry/system/auto_registrar.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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.
Instance Attribute Summary collapse
- #container ⇒ Object readonly private
Instance Method Summary collapse
- #call(component_dir) ⇒ Object private
- #finalize! ⇒ Object private
-
#initialize(container) ⇒ AutoRegistrar
constructor
private
A new instance of AutoRegistrar.
Constructor Details
#initialize(container) ⇒ AutoRegistrar
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AutoRegistrar.
18 19 20 |
# File 'lib/dry/system/auto_registrar.rb', line 18 def initialize(container) @container = container end |
Instance Attribute Details
#container ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/dry/system/auto_registrar.rb', line 16 def container @container end |
Instance Method Details
#call(component_dir) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 |
# File 'lib/dry/system/auto_registrar.rb', line 30 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! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 |
# File 'lib/dry/system/auto_registrar.rb', line 23 def finalize! container.component_dirs.each do |component_dir| call(component_dir) if component_dir.auto_register? end end |