Class: SmartCore::Container Private

Inherits:
Object
  • Object
show all
Includes:
DefinitionDSL
Defined in:
lib/smart_core/container.rb,
lib/smart_core/container/registry.rb,
lib/smart_core/container/exceptions.rb,
lib/smart_core/container/command_definer.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

Defined Under Namespace

Modules: Commands, DefinitionDSL, DependencyBuilder, DependencyCompatability, DependencyResolver, KeyGuard, Mixin, RegistryBuilder Classes: CommandDefiner, CommandSet, Dependency, Entity, MemoizedDependency, Namespace, Registry

Constant Summary collapse

Error =

Since:

  • 0.5.0

Class.new(SmartCore::Error)
ArgumentError =

Since:

  • 0.5.0

Class.new(SmartCore::ArgumentError)
NamespaceOverlapError =

Since:

  • 0.5.0

Class.new(Error)
DependencyOverlapError =

Since:

  • 0.5.0

Class.new(Error)
UnexistentDependencyError =

Since:

  • 0.5.0

Class.new(Error)
FrozenRegistryError =

Since:

  • 0.5.0

Class.new(SmartCore::FrozenError)
IncompatibleDependencyTree =

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.

Since:

  • 0.5.0

Class.new(Error)

Instance Method Summary collapse

Methods included from DefinitionDSL

included

Constructor Details

#initializevoid

Since:

  • 0.5.0



32
33
34
35
# File 'lib/smart_core/container.rb', line 32

def initialize
  build_registry
  @access_lock = Mutex.new
end

Instance Method Details

#freezevoid

This method returns an undefined value.

Since:

  • 0.5.0



56
57
58
# File 'lib/smart_core/container.rb', line 56

def freeze
  thread_safe { registry.freeze }
end

#frozen?Boolean

Returns:

  • (Boolean)

Since:

  • 0.5.0



64
65
66
# File 'lib/smart_core/container.rb', line 64

def frozen?
  thread_safe { registry.frozen? }
end

#namespace(namespace_name, &dependency_definitions) ⇒ void

This method returns an undefined value.

Parameters:

  • namespace_name (String, Symbol)
  • dependency_definitions (Block)

Since:

  • 0.5.0



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

def namespace(namespace_name, &dependency_definitions)
  thread_safe do
    registry.namespace(namespace_name, &dependency_definitions)
  end
end

#register(dependency_name, **options, &dependency_definition) ⇒ void

TODO:

option list

This method returns an undefined value.

Parameters:

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

Since:

  • 0.5.0



46
47
48
49
50
# File 'lib/smart_core/container.rb', line 46

def register(dependency_name, **options, &dependency_definition)
  thread_safe do
    registry.register(dependency_name, **options, &dependency_definition)
  end
end

#reload!void

This method returns an undefined value.

Since:

  • 0.5.0



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

def reload!
  thread_safe { build_registry }
end

#resolve(dependency_path) ⇒ Any

Parameters:

  • dependency_path (String, Symbol)

Returns:

  • (Any)

Since:

  • 0.5.0



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

def resolve(dependency_path)
  thread_safe do
    DependencyResolver.resolve(registry, dependency_path)
  end
end