Module: SmartCore::Container::DependencyResolver Private
- Defined in:
- lib/smart_core/container/dependency_resolver.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Route
Class Method Summary collapse
- .fetch(container, dependency_path) ⇒ SmartCore::Container, Any private
- .resolve(container, dependency_path) ⇒ SmartCore::Container, Any private
Class Method Details
.fetch(container, dependency_path) ⇒ SmartCore::Container, 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.
19 20 21 |
# File 'lib/smart_core/container/dependency_resolver.rb', line 19 def fetch(container, dependency_path) container.registry.resolve(dependency_path).reveal end |
.resolve(container, dependency_path) ⇒ SmartCore::Container, 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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/smart_core/container/dependency_resolver.rb', line 36 def resolve(container, dependency_path) entity = container Route.build(dependency_path).each do |cursor| entity = entity.registry.resolve(cursor.current_path) if cursor.last? && entity.is_a?(SmartCore::Container::Entities::Namespace) # rubocop:enable Metrics/LineLength raise(SmartCore::Container::ResolvingError.new(<<~MESSAGE, path_part: cursor.current_path)) Trying to resolve a namespace as a dependency MESSAGE # rubocop:disable Metrics/LineLength end if !cursor.last? && entity.is_a?(SmartCore::Container::Entities::Dependency) # rubocop:enable Metrics/LineLength raise(SmartCore::Container::ResolvingError.new(<<~MESSAGE, path_part: cursor.current_path)) Trying to resolve nonexistent dependency MESSAGE # rubocop:disable Metrics/LineLength end entity = entity.reveal end entity rescue SmartCore::Container::ResolvingError => error full_dependency_path = Route.build_path(dependency_path, error.path_part) raise(SmartCore::Container::ResolvingError.new(<<~MESSAGE, path_part: full_dependency_path)) #{error.} (incorrect path: "#{full_dependency_path}") MESSAGE end |