Skip to content

Commit 3b92e3c

Browse files
committed
Force everything to string
1 parent a0b5769 commit 3b92e3c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/dry/system/container.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ def load_component(key)
629629
load_local_component(component)
630630
elsif manifest_registrar.file_exists?(component)
631631
manifest_registrar.(component)
632-
elsif importer.namespace?(component.root_key&.to_s)
633-
load_imported_component(component.identifier, namespace: component.root_key&.to_s)
632+
elsif importer.namespace?(component.root_key)
633+
load_imported_component(component.identifier, namespace: component.root_key)
634634
elsif importer.namespace?(nil)
635635
load_imported_component(component.identifier, namespace: nil)
636636
end

lib/dry/system/importer.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def initialize(container)
3636

3737
# @api private
3838
def register(namespace:, container:, keys: nil)
39-
registry[namespace] = Item.new(
39+
registry[namespace_key(namespace)] = Item.new(
4040
namespace: namespace,
4141
container: container,
4242
import_keys: keys
@@ -45,12 +45,12 @@ def register(namespace:, container:, keys: nil)
4545

4646
# @api private
4747
def [](name)
48-
registry.fetch(name)
48+
registry.fetch(namespace_key(name))
4949
end
5050

5151
# @api private
5252
def key?(name)
53-
registry.key?(name)
53+
registry.key?(namespace_key(name))
5454
end
5555
alias_method :namespace?, :key?
5656

@@ -76,6 +76,12 @@ def import(namespace, keys: Undefined)
7676

7777
private
7878

79+
def namespace_key(namespace)
80+
return nil if namespace.nil?
81+
82+
namespace.to_s
83+
end
84+
7985
def keys_to_import(keys, item)
8086
keys
8187
.then { (arr = item.import_keys) ? _1 & arr : _1 }

0 commit comments

Comments
 (0)