Class: SmartCore::Injection::Locator::ContainerProxy Private
- Inherits:
-
Object
- Object
- SmartCore::Injection::Locator::ContainerProxy
- Defined in:
- lib/smart_core/injection/locator/container_proxy.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.
Instance Method Summary collapse
- #initialize(registered_containers, explicitly_passed_container) ⇒ void constructor private
- #observe(import_path, &observer) ⇒ void private
- #resolve_dependency(dependency_path) ⇒ Any private
Constructor Details
#initialize(registered_containers, explicitly_passed_container) ⇒ void
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 15 16 17 |
# File 'lib/smart_core/injection/locator/container_proxy.rb', line 12 def initialize(registered_containers, explicitly_passed_container) @registered_containers = registered_containers @explicitly_passed_container = explicitly_passed_container @observers = Hash.new { |h, k| h[k] = [] } registered_containers.listen_addings { |container| listen_changes(container) } end |
Instance Method Details
#observe(import_path, &observer) ⇒ void
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.
This method returns an undefined value.
53 54 55 56 57 58 59 |
# File 'lib/smart_core/injection/locator/container_proxy.rb', line 53 def observe(import_path, &observer) register_observer(import_path, observer) each_container do |container| container.observe(import_path) { |path, cntr| process_changement(cntr, path) } end end |
#resolve_dependency(dependency_path) ⇒ Any
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/smart_core/injection/locator/container_proxy.rb', line 27 def resolve_dependency(dependency_path) resolving_error = nil each_container do |container| begin # rubocop:disable Style/RedundantBegin return container.resolve(dependency_path) rescue SmartCore::Container::ResolvingError => error resolving_error = error end end unless resolving_error raise(SmartCore::Injection::NoRegisteredContainersError, <<~ERROR_MESSAGE) You haven't registered any containers for import. ERROR_MESSAGE else raise(resolving_error) end end |