Module: SmartCore::Container::RegistryBuilder Private

Defined in:
lib/smart_core/container/registry_builder.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.build(container, ignored_definition_commands: [], ignored_instantiation_commands: []) ⇒ SmartCore::Container::Registry

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:

  • ignored_definition_commands (Hash) (defaults to: [])

    a customizable set of options

  • ignored_instantiation_commands (Hash) (defaults to: [])

    a customizable set of options

Options Hash (ignored_definition_commands:):

  • ] (Array<Class::SmartCore::Container::DefinitionDSL::Commands::Base>)

Options Hash (ignored_instantiation_commands:):

  • ] (Array<Class::SmartCore::Container::DefinitionDSL::Commands::Base>)

Returns:

Since:

  • 0.1.0



15
16
17
18
19
20
# File 'lib/smart_core/container/registry_builder.rb', line 15

def build(container, ignored_definition_commands: [], ignored_instantiation_commands: [])
  SmartCore::Container::Registry.new.tap do |registry|
    define(container.class, registry, ignored_commands: ignored_definition_commands)
    instantiate(container.class, registry, ignored_commands: ignored_instantiation_commands)
  end
end

.define(container_klass, registry, ignored_commands: []) ⇒ 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:

Options Hash (ignored_commands:):

Since:

  • 0.1.0



29
30
31
32
33
34
# File 'lib/smart_core/container/registry_builder.rb', line 29

def define(container_klass, registry, ignored_commands: [])
  container_klass.__container_definition_commands__.each do |command|
    next if ignored_commands.include?(command.class)
    command.call(registry)
  end
end

.instantiate(container_klass, registry, ignored_commands: []) ⇒ 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:

Options Hash (ignored_commands:):

Since:

  • 0.1.0



43
44
45
46
47
48
# File 'lib/smart_core/container/registry_builder.rb', line 43

def instantiate(container_klass, registry, ignored_commands: [])
  container_klass.__container_instantiation_commands__.each do |command|
    next if ignored_commands.include?(command.class)
    command.call(registry)
  end
end