Class: SmartCore::Container::Registry Private
- Inherits:
-
Object
- Object
- SmartCore::Container::Registry
- Includes:
- Enumerable
- Defined in:
- lib/smart_core/container/registry.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.
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_MEMOIZATION_BEHAVIOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
false
- DEFAULT_ITERATION_YIELD_BEHAVIOUR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
false
- DEFAULT_KEY_EXTRACTION_BEHAVIOUR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
false
Instance Attribute Summary collapse
- #registry ⇒ Hash<Symbol,SmartCore::Container::Entity> readonly private
Instance Method Summary collapse
- #each(&block) ⇒ Enumerable private
- #each_dependency(root_dependency_name = nil, yield_all: DEFAULT_ITERATION_YIELD_BEHAVIOUR, &block) ⇒ Enumerable private
- #freeze! ⇒ void private
- #frozen? ⇒ Boolean private
- #hash_tree(resolve_dependencies: false) ⇒ Hash<String|Symbol,SmartCore::Container::Entities::Base|Any> (also: #to_h, #to_hash) private
- #initialize ⇒ void constructor private
- #keys(all_variants: DEFAULT_KEY_EXTRACTION_BEHAVIOUR) ⇒ Array<String> private
- #register_dependency(name, memoize: DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition) ⇒ void private
- #register_namespace(name, host_container = SmartCore::Container::NO_HOST_CONTAINER, &dependencies_definition) ⇒ void private
- #resolve(entity_path) ⇒ SmartCore::Container::Entity private
Constructor Details
#initialize ⇒ 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.
40 41 42 43 |
# File 'lib/smart_core/container/registry.rb', line 40 def initialize @registry = {} @lock = SmartCore::Engine::ReadWriteLock.new end |
Instance Attribute Details
#registry ⇒ Hash<Symbol,SmartCore::Container::Entity> (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.
33 34 35 |
# File 'lib/smart_core/container/registry.rb', line 33 def registry @registry end |
Instance Method Details
#each(&block) ⇒ Enumerable
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.
107 108 109 |
# File 'lib/smart_core/container/registry.rb', line 107 def each(&block) @lock.read_sync { enumerate(&block) } end |
#each_dependency(root_dependency_name = nil, yield_all: DEFAULT_ITERATION_YIELD_BEHAVIOUR, &block) ⇒ Enumerable
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.
119 120 121 122 123 124 125 |
# File 'lib/smart_core/container/registry.rb', line 119 def each_dependency( root_dependency_name = nil, yield_all: DEFAULT_ITERATION_YIELD_BEHAVIOUR, &block ) @lock.read_sync { iterate(root_dependency_name, yield_all: yield_all, &block) } end |
#freeze! ⇒ 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.
88 89 90 |
# File 'lib/smart_core/container/registry.rb', line 88 def freeze! @lock.write_sync { freeze_state! } end |
#frozen? ⇒ 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.
97 98 99 |
# File 'lib/smart_core/container/registry.rb', line 97 def frozen? @lock.read_sync { state_frozen? } end |
#hash_tree(resolve_dependencies: false) ⇒ Hash<String|Symbol,SmartCore::Container::Entities::Base|Any> Also known as: to_h, to_hash
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.
142 143 144 |
# File 'lib/smart_core/container/registry.rb', line 142 def hash_tree(resolve_dependencies: false) @lock.read_sync { build_hash_tree(resolve_dependencies: resolve_dependencies) } end |
#keys(all_variants: DEFAULT_KEY_EXTRACTION_BEHAVIOUR) ⇒ Array<String>
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.
133 134 135 |
# File 'lib/smart_core/container/registry.rb', line 133 def keys(all_variants: DEFAULT_KEY_EXTRACTION_BEHAVIOUR) @lock.read_sync { extract_keys(all_variants: all_variants) } end |
#register_dependency(name, memoize: DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition) ⇒ 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.
63 64 65 |
# File 'lib/smart_core/container/registry.rb', line 63 def register_dependency(name, memoize: DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition) @lock.write_sync { add_dependency(name, dependency_definition, memoize) } end |
#register_namespace(name, host_container = SmartCore::Container::NO_HOST_CONTAINER, &dependencies_definition) ⇒ 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.
75 76 77 78 79 80 81 |
# File 'lib/smart_core/container/registry.rb', line 75 def register_namespace( name, host_container = SmartCore::Container::NO_HOST_CONTAINER, &dependencies_definition ) @lock.write_sync { add_namespace(name, host_container, dependencies_definition) } end |
#resolve(entity_path) ⇒ SmartCore::Container::Entity
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/smart_core/container/registry.rb', line 51 def resolve(entity_path) @lock.read_sync { fetch_entity(entity_path) } end |