Class: SmartCore::Container
- Inherits:
-
Object
- Object
- SmartCore::Container
show all
- Includes:
- DefinitionDSL
- Defined in:
- lib/smart_core/container.rb,
lib/smart_core/container/errors.rb,
lib/smart_core/container/definition_dsl.rb
Overview
Defined Under Namespace
Modules: DefinitionDSL, DependencyCompatability, DependencyResolver, Entities, KeyGuard, Mixin, RegistryBuilder
Classes: ArbitaryLock, Registry, ResolvingError
Constant Summary
collapse
- Error =
Class.new(SmartCore::Error)
- ArgumentError =
Class.new(SmartCore::ArgumentError)
- IncompatibleEntityNameError =
Class.new(ArgumentError)
- FrozenRegistryError =
Class.new(SmartCore::FrozenError)
- FetchError =
Class.new(Error)
- DependencyOverNamespaceOverlapError =
Class.new(Error)
- NamespaceOverDependencyOverlapError =
Class.new(Error)
Instance Attribute Summary collapse
Instance Method Summary
collapse
included
Constructor Details
#initialize ⇒ void
30
31
32
33
|
# File 'lib/smart_core/container.rb', line 30
def initialize
build_registry!
@access_lock = ArbitaryLock.new
end
|
Instance Attribute Details
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.
24
25
26
|
# File 'lib/smart_core/container.rb', line 24
def registry
@registry
end
|
Instance Method Details
#fetch(dependency_path) ⇒ Any
71
72
73
|
# File 'lib/smart_core/container.rb', line 71
def fetch(dependency_path)
thread_safe { DependencyResolver.fetch(self, dependency_path) }
end
|
#freeze! ⇒ void
This method returns an undefined value.
79
80
81
|
# File 'lib/smart_core/container.rb', line 79
def freeze!
thread_safe { registry.freeze! }
end
|
#frozen? ⇒ Boolean
87
88
89
|
# File 'lib/smart_core/container.rb', line 87
def frozen?
thread_safe { registry.frozen? }
end
|
#hash_tree(resolve_dependencies: false) ⇒ Hash<String|Symbol,SmartCore::Container::Entities::Base|Any>
Also known as:
to_h, to_hash
104
105
106
|
# File 'lib/smart_core/container.rb', line 104
def hash_tree(resolve_dependencies: false)
thread_safe { registry.hash_tree(resolve_dependencies: resolve_dependencies) }
end
|
#namespace(namespace_name, &dependencies_definition) ⇒ void
This method returns an undefined value.
51
52
53
|
# File 'lib/smart_core/container.rb', line 51
def namespace(namespace_name, &dependencies_definition)
thread_safe { registry.register_namespace(namespace_name, &dependencies_definition) }
end
|
#register(dependency_name, &dependency_definition) ⇒ void
This method returns an undefined value.
41
42
43
|
# File 'lib/smart_core/container.rb', line 41
def register(dependency_name, &dependency_definition)
thread_safe { registry.register_dependency(dependency_name, &dependency_definition) }
end
|
#reload! ⇒ void
This method returns an undefined value.
95
96
97
|
# File 'lib/smart_core/container.rb', line 95
def reload!
thread_safe { build_registry! }
end
|
#resolve(dependency_path) ⇒ Any
Also known as:
[]
61
62
63
|
# File 'lib/smart_core/container.rb', line 61
def resolve(dependency_path)
thread_safe { DependencyResolver.resolve(self, dependency_path) }
end
|