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.

Since:

  • 0.5.0

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.5.0



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

def initialize
  @access_lock = Mutex.new
  @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.5.0



86
87
88
# File 'lib/smart_core/container/registry.rb', line 86

def each(&block)
  thread_safe { block_given? ? registry.each_value(&block) : registry.each_value }
end

#freezevoid

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.5.0



23
24
25
# File 'lib/smart_core/container/registry.rb', line 23

def freeze
  thread_safe { freeze_state }
end

#frozen?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.5.0



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

def frozen?
  thread_safe { state_frozen? }
end

#namespace(name, &dependency_definitions) ⇒ 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_definitions (Block)

Since:

  • 0.5.0



70
71
72
73
74
75
76
77
78
79
# File 'lib/smart_core/container/registry.rb', line 70

def namespace(name, &dependency_definitions)
  thread_safe do
    raise(
      SmartCore::Container::FrozenRegistryError,
      'Can not modify frozen registry'
    ) if state_frozen?

    append_namespace(name, dependency_definitions)
  end
end

#register(name, **options, &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.

TODO:

option list

This method returns an undefined value.

Parameters:

  • name (String, Symbol)
  • options (Hash<Symbol,Any>)
  • dependency_definition (Block)

Since:

  • 0.5.0



53
54
55
56
57
58
59
60
61
62
# File 'lib/smart_core/container/registry.rb', line 53

def register(name, **options, &dependency_definition)
  thread_safe do
    raise(
      SmartCore::Container::FrozenRegistryError,
      'Can not modify frozen registry'
    ) if state_frozen?

    append_dependency(name, dependency_definition, **options)
  end
end

#resolve(dependency_path) ⇒ SmartCore::Container::Namespace, SmartCore::Container::Dependnecy

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:

  • dependency_path (String, Symbol)

Returns:

Since:

  • 0.5.0



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

def resolve(dependency_path)
  thread_safe { fetch_dependency(dependency_path) }
end

#to_hHash<Symbol,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.

Returns:

  • (Hash<Symbol,Any>)

Since:

  • 0.5.0



94
95
96
# File 'lib/smart_core/container/registry.rb', line 94

def to_h
  # TODO: implement :)
end