Class: Dry::System::ManifestRegistrar Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/system/manifest_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 manifest registration implementation

This is configured by default for every System::Container. The manifest registrar is responsible for loading manifest files that contain code to manually register certain objects with the container.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ ManifestRegistrar

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 ManifestRegistrar.



22
23
24
25
# File 'lib/dry/system/manifest_registrar.rb', line 22

def initialize(container)
  @container = container
  @config = container.config
end

Instance Attribute Details

#configObject (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.



19
20
21
# File 'lib/dry/system/manifest_registrar.rb', line 19

def config
  @config
end

#containerObject (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/manifest_registrar.rb', line 16

def container
  @container
end

Instance Method Details

#call(component) ⇒ 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.



35
36
37
# File 'lib/dry/system/manifest_registrar.rb', line 35

def call(component)
  require(root.join(config.registrations_dir, component.root_key.to_s))
end

#file_exists?(component) ⇒ 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.

Returns:

  • (Boolean)


40
41
42
# File 'lib/dry/system/manifest_registrar.rb', line 40

def file_exists?(component)
  File.exist?(File.join(registrations_dir, "#{component.root_key}#{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.



28
29
30
31
32
# File 'lib/dry/system/manifest_registrar.rb', line 28

def finalize!
  ::Dir[registrations_dir.join(RB_GLOB)].sort.each do |file|
    call(Identifier.new(File.basename(file, RB_EXT)))
  end
end