Class: Dry::System::Importer Private
- Inherits:
-
Object
- Object
- Dry::System::Importer
- 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
- #container ⇒ Object readonly private
- #registry ⇒ Object readonly private
- #separator ⇒ Object readonly private
Instance Method Summary collapse
- #[](name) ⇒ Object private
- #call(ns, other) ⇒ Object private
- #finalize! ⇒ Object private
-
#initialize(container) ⇒ Importer
constructor
private
A new instance of Importer.
- #key?(name) ⇒ Boolean private
- #register(other) ⇒ Object private
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.
19 20 21 22 23 |
# File 'lib/dry/system/importer.rb', line 19 def initialize(container) @container = container @separator = container.config.namespace_separator @registry = {} end |
Instance Attribute Details
#container ⇒ Object (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.
12 13 14 |
# File 'lib/dry/system/importer.rb', line 12 def container @container end |
#registry ⇒ Object (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 registry @registry end |
#separator ⇒ Object (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 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.
34 35 36 |
# File 'lib/dry/system/importer.rb', line 34 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.
44 45 46 |
# File 'lib/dry/system/importer.rb', line 44 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.
26 27 28 29 30 31 |
# File 'lib/dry/system/importer.rb', line 26 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.
39 40 41 |
# File 'lib/dry/system/importer.rb', line 39 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.
49 50 51 |
# File 'lib/dry/system/importer.rb', line 49 def register(other) registry.update(other) end |