Class: Dry::Core::Container::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/core/container/namespace.rb

Overview

Create a namespace to be imported

Examples:


ns = Dry::Core::Container::Namespace.new('name') do
  register('item', 'item')
end

container = Dry::Core::Container.new

container.import(ns)

container.resolve('name.item')
=> 'item'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) { ... } ⇒ Dry::Core::Container::Namespace

Create a new namespace

Parameters:

  • name (Mixed)

    The name of the namespace

Yields:

  • The block to evaluate when the namespace is imported



40
41
42
43
# File 'lib/dry/core/container/namespace.rb', line 40

def initialize(name, &block)
  @name = name
  @block = block
end

Instance Attribute Details

#blockProc (readonly)

Returns The block to be executed when the namespace is imported.

Returns:

  • (Proc)

    The block to be executed when the namespace is imported



28
29
30
# File 'lib/dry/core/container/namespace.rb', line 28

def block
  @block
end

#nameMixed (readonly)

Returns The namespace (name).

Returns:

  • (Mixed)

    The namespace (name)



25
26
27
# File 'lib/dry/core/container/namespace.rb', line 25

def name
  @name
end