Class: Dry::Container::NamespaceDSL Private

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/dry/container/namespace_dsl.rb

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.

Instance Method Summary collapse

Constructor Details

#initialize(container, namespace, namespace_separator) { ... } ⇒ Mixed

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.

DSL for defining namespaces

Parameters:

  • container (Dry::Container::Mixin)

    The container

  • namespace (String)

    The namespace (name)

  • namespace_separator (String)

    The namespace separator

Yields:

  • The block to evaluate to define the namespace



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dry/container/namespace_dsl.rb', line 23

def initialize(container, namespace, namespace_separator, &block)
  @namespace = namespace
  @namespace_separator = namespace_separator

  super(container)

  if block.arity.zero?
    instance_eval(&block)
  else
    yield self
  end
end

Instance Method Details

#import(namespace) ⇒ Object

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.



44
45
46
47
48
# File 'lib/dry/container/namespace_dsl.rb', line 44

def import(namespace)
  namespace(namespace.name, &namespace.block)

  self
end

#namespace(namespace, &block) ⇒ Object

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.



40
41
42
# File 'lib/dry/container/namespace_dsl.rb', line 40

def namespace(namespace, &block)
  super(namespaced(namespace), &block)
end

#register(key, *args, &block) ⇒ Object

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.



36
37
38
# File 'lib/dry/container/namespace_dsl.rb', line 36

def register(key, *args, &block)
  super(namespaced(key), *args, &block)
end

#resolve(key) ⇒ Object

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.



50
51
52
# File 'lib/dry/container/namespace_dsl.rb', line 50

def resolve(key)
  super(namespaced(key))
end