Method: PDK::Config::Namespace#mount

Defined in:
lib/pdk/config/namespace.rb

#mount(key, obj, &block) ⇒ self

Mount a provided [self] (or subclass) into the namespace.

Parameters:

  • key (String, Symbol)

    the name of the namespace to be mounted.

  • obj (self)

    the namespace to be mounted.

  • block (Proc)

    a block to be evaluated within the instance of the newly mounted namespace.

Returns:

  • (self)

    the mounted namespace.

Raises:

  • (ArgumentError)

    if the object to be mounted is not a self or subclass thereof.



64
65
66
67
68
69
70
# File 'lib/pdk/config/namespace.rb', line 64

def mount(key, obj, &block)
  raise ArgumentError, _('Only PDK::Config::Namespace objects can be mounted into a namespace') unless obj.is_a?(PDK::Config::Namespace)
  obj.parent = self
  obj.name = key.to_s
  obj.instance_eval(&block) if block_given?
  @mounts[key.to_s] = obj
end