Class: Dry::Core::Container::NamespaceDSL Private

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/dry/core/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::Core::Container::Mixin)

    The container

  • namespace (String)

    The namespace (name)

  • namespace_separator (String)

    The namespace separator

Yields:

  • The block to evaluate to define the namespace



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

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.



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

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.



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

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.



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

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.



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

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