class SmartCore::Container::Entities::Namespace

@api private @since 0.1.0

Attributes

container_klass[R]

@return [Class<SmartCore::Container>]

@api private @since 0.1.0

host_container[R]

@return [NilClass, SmartCore::Container]

@api private @since 0.8.01

Public Class Methods

new(namespace_name, host_container = SmartCore::Container::NO_HOST_CONTAINER) click to toggle source

@param namespace_name [String] @param host_container [NilClass, SmartCore::Container] @return [void]

@api private @since 0.1.0 @version 0.8.1

# File lib/smart_core/container/entities/namespace.rb, line 25
def initialize(namespace_name, host_container = SmartCore::Container::NO_HOST_CONTAINER)
  super(namespace_name)
  @container_klass = Class.new(SmartCore::Container)
  @container_instance = nil
  @host_container = host_container
  @lock = SmartCore::Container::ArbitraryLock.new
end

Public Instance Methods

append_definitions(dependencies_definition) click to toggle source

@param dependencies_definition [Proc] @return [void]

@api private @since 0.1.0

# File lib/smart_core/container/entities/namespace.rb, line 48
def append_definitions(dependencies_definition)
  thread_safe { container_klass.instance_eval(&dependencies_definition) }
end
freeze!() click to toggle source

@return [void]

@api private @since 0.1.0

# File lib/smart_core/container/entities/namespace.rb, line 56
def freeze!
  thread_safe { container_instance.freeze! }
end
reveal(runtime_host_container = SmartCore::Container::NO_HOST_CONTAINER) click to toggle source

@param runtime_host_container [SmartCore::Container, NilClass] @return [SmartCore::Container]

@api private @since 0.1.0 @version 0.8.1

# File lib/smart_core/container/entities/namespace.rb, line 39
def reveal(runtime_host_container = SmartCore::Container::NO_HOST_CONTAINER)
  thread_safe { container_instance(runtime_host_container) }
end

Private Instance Methods

container_instance(runtime_host_container = SmartCore::Container::NO_HOST_CONTAINER) click to toggle source

@param runtime_host_container [SmartCore::Container, NilClass] @return [SmartCore::Container]

@api private @since 0.1.0 @version 0.8.1

# File lib/smart_core/container/entities/namespace.rb, line 74
def container_instance(runtime_host_container = SmartCore::Container::NO_HOST_CONTAINER)
  @host_container ||= runtime_host_container
  @container_instance ||= container_klass.new(
    host_container: @host_container,
    host_path: @host_container && namespace_name
  )
end
thread_safe(&block) click to toggle source

@param block [Block] @return [Any]

@api private @since 0.1.0

# File lib/smart_core/container/entities/namespace.rb, line 87
def thread_safe(&block)
  @lock.thread_safe(&block)
end