Sha256: 2a65a1daf954a30feffe6e9fc7da42b85cf04978e6e730172f7d56fe644768da

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

module Dry
  class Container
    # Create a namespace to be imported
    #
    # @example
    #
    #   ns = Dry::Container::Namespace.new('name') do
    #     register('item', 'item')
    #   end
    #
    #   container = Dry::Container.new
    #
    #   container.import(ns)
    #
    #   container.resolve('name.item')
    #   => 'item'
    #
    #
    # @api public
    class Namespace
      attr_reader :name, :block
      # Create a new namespace
      #
      # @param [Mixed] name
      #   The name of the namespace
      # @yield
      #   The block to evaluate when the namespace is imported
      #
      # @return [Dry::Container::Namespace]
      #
      # @api public
      def initialize(name, &block)
        @name = name
        @block = block
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-container-0.2.2 lib/dry/container/namespace.rb