Class: SmartCore::Container::Registry Private

Inherits:
Object
  • Object
show all
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

Since:

  • 0.7.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.7.0



20
21
22
23
# File 'lib/smart_core/container/registry.rb', line 20

def initialize
  @registry = {}
  @access_lock = SmartCore::Container::ArbitaryLock.new
end

Instance Attribute Details

#registryHash<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.

Returns:

  • (Hash<Symbol,SmartCore::Container::Entity>)

Since:

  • 0.7.0



14
15
16
# File 'lib/smart_core/container/registry.rb', line 14

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.

Parameters:

  • block (Block)

Returns:

  • (Enumerable)

Since:

  • 0.7.0



75
76
77
# File 'lib/smart_core/container/registry.rb', line 75

def each(&block)
  thread_safe { enumerate(&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.

Since:

  • 0.7.0



58
59
60
# File 'lib/smart_core/container/registry.rb', line 58

def freeze!
  thread_safe { 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.

Returns:

  • (Boolean)

Since:

  • 0.7.0



66
67
68
# File 'lib/smart_core/container/registry.rb', line 66

def frozen?
  thread_safe { 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.

Returns:

Since:

  • 0.7.0



83
84
85
# File 'lib/smart_core/container/registry.rb', line 83

def hash_tree(resolve_dependencies: false)
  thread_safe { build_hash_tree(resolve_dependencies: resolve_dependencies) }
end

#register_dependency(name, &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.

Parameters:

  • name (String, Symbol)
  • dependency_definition (Block)

Since:

  • 0.7.0



40
41
42
# File 'lib/smart_core/container/registry.rb', line 40

def register_dependency(name, &dependency_definition)
  thread_safe { add_dependency(name, dependency_definition) }
end

#register_namespace(name, &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.

Parameters:

  • name (String, Symbol)
  • dependencies_definition (Block)

Since:

  • 0.7.0



50
51
52
# File 'lib/smart_core/container/registry.rb', line 50

def register_namespace(name, &dependencies_definition)
  thread_safe { add_namespace(name, 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.

Parameters:

  • entity_path (String, Symbol)

Returns:

  • (SmartCore::Container::Entity)

Since:

  • 0.7.0



30
31
32
# File 'lib/smart_core/container/registry.rb', line 30

def resolve(entity_path)
  thread_safe { fetch_entity(entity_path) }
end