Class: Dry::System::ManualRegistrar Private
- Inherits:
-
Object
- Object
- Dry::System::ManualRegistrar
- Defined in:
- lib/dry/system/manual_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 manual registration implementation
This is currently configured by default for every System::Container. Manual registrar objects are responsible for loading files from configured manual registration paths, which should hold code to explicitly register certain objects with the container.
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
- #container ⇒ Object readonly private
Instance Method Summary collapse
- #call(name) ⇒ Object private
- #file_exists?(name) ⇒ Boolean private
- #finalize! ⇒ Object private
-
#initialize(container) ⇒ ManualRegistrar
constructor
private
A new instance of ManualRegistrar.
Constructor Details
#initialize(container) ⇒ ManualRegistrar
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 ManualRegistrar.
18 19 20 21 |
# File 'lib/dry/system/manual_registrar.rb', line 18 def initialize(container) @container = container @config = container.config end |
Instance Attribute Details
#config ⇒ 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/manual_registrar.rb', line 16 def config @config end |
#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.
14 15 16 |
# File 'lib/dry/system/manual_registrar.rb', line 14 def container @container end |
Instance Method Details
#call(name) ⇒ 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.
31 32 33 34 35 |
# File 'lib/dry/system/manual_registrar.rb', line 31 def call(name) name = name.respond_to?(:root_key) ? name.root_key.to_s : name require(root.join(config.registrations_dir, name)) end |
#file_exists?(name) ⇒ Boolean
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.
37 38 39 40 41 |
# File 'lib/dry/system/manual_registrar.rb', line 37 def file_exists?(name) name = name.respond_to?(:root_key) ? name.root_key.to_s : name File.exist?(File.join(registrations_dir, "#{name}#{RB_EXT}")) 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.
24 25 26 27 28 |
# File 'lib/dry/system/manual_registrar.rb', line 24 def finalize! Dir[registrations_dir.join(RB_GLOB)].each do |file| call(File.basename(file, RB_EXT)) end end |