Skip to content

Commit 65a3bb1

Browse files
committed
Rename manual registrar to manifest registrar
This will allow us to reserve the term "manual registration" for any instance of a user directly calling `#register` on the container.
1 parent 5679b57 commit 65a3bb1

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

lib/dry/system/container.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
require "dry/system/identifier"
1919
require "dry/system/importer"
2020
require "dry/system/indirect_component"
21-
require "dry/system/manual_registrar"
21+
require "dry/system/manifest_registrar"
2222
require "dry/system/plugins"
2323
require "dry/system/provider_registrar"
2424
require "dry/system/provider"
@@ -81,11 +81,11 @@ class Container
8181
setting :root, default: Pathname.pwd.freeze, constructor: -> path { Pathname(path) }
8282
setting :provider_dirs, default: ["system/providers"]
8383
setting :bootable_dirs # Deprecated for provider_dirs, see .provider_paths below
84-
setting :registrations_dir, default: "container"
84+
setting :registrations_dir, default: "system/registrations"
8585
setting :component_dirs, default: Config::ComponentDirs.new, cloneable: true
8686
setting :inflector, default: Dry::Inflector.new
8787
setting :auto_registrar, default: Dry::System::AutoRegistrar
88-
setting :manual_registrar, default: Dry::System::ManualRegistrar
88+
setting :manifest_registrar, default: Dry::System::ManifestRegistrar
8989
setting :provider_registrar, default: Dry::System::ProviderRegistrar
9090
setting :importer, default: Dry::System::Importer
9191

@@ -321,7 +321,7 @@ def finalize!(freeze: true, &block)
321321

322322
importer.finalize!
323323
providers.finalize!
324-
manual_registrar.finalize!
324+
manifest_registrar.finalize!
325325
auto_registrar.finalize!
326326

327327
@__finalized__ = true
@@ -412,7 +412,7 @@ def add_to_load_path!(*dirs)
412412

413413
# @api public
414414
def load_registrations!(name)
415-
manual_registrar.(name)
415+
manifest_registrar.(name)
416416
self
417417
end
418418

@@ -563,8 +563,8 @@ def auto_registrar
563563
end
564564

565565
# @api private
566-
def manual_registrar
567-
@manual_registrar ||= config.manual_registrar.new(self)
566+
def manifest_registrar
567+
@manifest_registrar ||= config.manifest_registrar.new(self)
568568
end
569569

570570
# @api private
@@ -616,8 +616,8 @@ def load_component(key)
616616

617617
if component.loadable?
618618
load_local_component(component)
619-
elsif manual_registrar.file_exists?(component)
620-
manual_registrar.(component)
619+
elsif manifest_registrar.file_exists?(component)
620+
manifest_registrar.(component)
621621
elsif importer.key?(component.identifier.root_key)
622622
load_imported_component(component.identifier)
623623
end
@@ -646,8 +646,8 @@ def load_imported_component(identifier)
646646
def find_component(key)
647647
# Find the first matching component from within the configured component dirs.
648648
# If no matching component is found, return a null component; this fallback is
649-
# important because the component may still be loadable via the manual registrar
650-
# or an imported container.
649+
# important because the component may still be loadable via the manifest
650+
# registrar or an imported container.
651651
component_dirs.detect { |dir|
652652
if (component = dir.component_for_key(key))
653653
break component

lib/dry/system/indirect_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Dry
66
module System
77
# An indirect component is a component that cannot be directly from a source file
88
# directly managed by the container. It may be component that needs to be loaded
9-
# indirectly, either via a manual registration file or an imported container
9+
# indirectly, either via a registration manifest file or an imported container
1010
#
1111
# Indirect components are an internal abstraction and, unlike ordinary components, are
1212
# not exposed to users via component dir configuration hooks.

lib/dry/system/manual_registrar.rb renamed to lib/dry/system/manifest_registrar.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44

55
module Dry
66
module System
7-
# Default manual registration implementation
7+
# Default manifest registration implementation
88
#
9-
# This is currently configured by default for every System::Container.
10-
# Manual registrar objects are responsible for loading files from configured
11-
# manual registration paths, which should hold code to explicitly register
12-
# certain objects with the container.
9+
# This is configured by default for every System::Container. The manifest registrar is
10+
# responsible for loading manifest files that contain code to manually register
11+
# certain objects in the container.
1312
#
1413
# @api private
15-
class ManualRegistrar
14+
class ManifestRegistrar
15+
# @api private
1616
attr_reader :container
1717

18+
# @api private
1819
attr_reader :config
1920

21+
# @api private
2022
def initialize(container)
2123
@container = container
2224
@config = container.config
@@ -31,9 +33,10 @@ def finalize!
3133

3234
# @api private
3335
def call(component)
34-
require(root.join(config.registrations_dir, component.root_key.to_s))
36+
require(root.join(registrations_dir, component.root_key.to_s))
3537
end
3638

39+
# @api private
3740
def file_exists?(component)
3841
File.exist?(File.join(registrations_dir, "#{component.root_key}#{RB_EXT}"))
3942
end

spec/integration/container/lazy_loading/manual_registration_spec.rb renamed to spec/integration/container/lazy_loading/manifest_registration_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe "Lazy-loading manual registration files" do
3+
RSpec.describe "Lazy-loading registration manifest files" do
44
before do
55
module Test
66
class Container < Dry::System::Container
77
configure do |config|
8-
config.root = SPEC_ROOT.join("fixtures/manual_registration").realpath
8+
config.root = SPEC_ROOT.join("fixtures/manifest_registration").realpath
99
end
1010

1111
add_to_load_path!("lib")
1212
end
1313
end
1414
end
1515

16-
it "loads a manual registration file if the component could not be found" do
16+
it "loads a registration manifest file if the component could not be found" do
1717
expect(Test::Container["foo.special"]).to be_a(Test::Foo)
1818
expect(Test::Container["foo.special"].name).to eq "special"
1919
end

0 commit comments

Comments
 (0)