class Dry::System::ManualRegistrar

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.

@api private

Attributes

config[R]
container[R]

Public Class Methods

new(container) click to toggle source
# File lib/dry/system/manual_registrar.rb, line 20
def initialize(container)
  @container = container
  @config = container.config
end

Public Instance Methods

call(name) click to toggle source

@api private

# File lib/dry/system/manual_registrar.rb, line 33
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) click to toggle source
# File lib/dry/system/manual_registrar.rb, line 39
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!() click to toggle source

@api private

# File lib/dry/system/manual_registrar.rb, line 26
def finalize!
  ::Dir[registrations_dir.join(RB_GLOB)].sort.each do |file|
    call(File.basename(file, RB_EXT))
  end
end

Private Instance Methods

registrations_dir() click to toggle source

@api private

# File lib/dry/system/manual_registrar.rb, line 48
def registrations_dir
  root.join(config.registrations_dir)
end
root() click to toggle source

@api private

# File lib/dry/system/manual_registrar.rb, line 53
def root
  container.root
end