Class: Dry::System::Importer Private

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

This is currently configured by default for every System::Container. Importer objects are responsible for importing components from one container to another. This is used in cases where an application is split into multiple sub-systems.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ Importer

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



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

def initialize(container)
  @container = container
  @separator = container.config.namespace_separator
  @registry = {}
end

Instance Attribute Details

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



14
15
16
# File 'lib/dry/system/importer.rb', line 14

def container
  @container
end

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



18
19
20
# File 'lib/dry/system/importer.rb', line 18

def registry
  @registry
end

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

def separator
  @separator
end

Instance Method Details

#[](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.



36
37
38
# File 'lib/dry/system/importer.rb', line 36

def [](name)
  registry.fetch(name)
end

#call(ns, other) ⇒ 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.



46
47
48
# File 'lib/dry/system/importer.rb', line 46

def call(ns, other)
  container.merge(other, namespace: ns)
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
33
# File 'lib/dry/system/importer.rb', line 28

def finalize!
  registry.each do |name, container|
    call(name, container.finalize!)
  end
  self
end

#key?(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.

Returns:

  • (Boolean)


41
42
43
# File 'lib/dry/system/importer.rb', line 41

def key?(name)
  registry.key?(name)
end

#register(other) ⇒ 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.



51
52
53
# File 'lib/dry/system/importer.rb', line 51

def register(other)
  registry.update(other)
end