Sha256: 25d4246a070cfb3819bebb92ecaa5bf86fdade3866c307c14f2fa9a68dff8dd1

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

module Dry
  module System
    # Default importer implementation
    #
    # This is currently configured by default for every System::Container.
    # Importer objects are responsible for importing components from one
    # container to another. This is used in cases where an application is split
    # into multiple sub-systems.
    #
    # @api private
    class Importer
      attr_reader :container

      attr_reader :separator

      attr_reader :registry

      # @api private
      def initialize(container)
        @container = container
        @separator = container.config.namespace_separator
        @registry = {}
      end

      # @api private
      def finalize!
        registry.each do |name, container|
          call(name, container.finalize!)
        end
      end

      # @api private
      def [](name)
        registry.fetch(name)
      end

      # @api private
      def key?(name)
        registry.key?(name)
      end

      # @api private
      def call(ns, other)
        container.merge(other, namespace: ns)
      end

      # @api private
      def register(other)
        registry.update(other)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dry-system-0.10.1 lib/dry/system/importer.rb
dry-system-0.10.0 lib/dry/system/importer.rb
dry-system-0.9.2 lib/dry/system/importer.rb
dry-system-0.9.1 lib/dry/system/importer.rb
dry-system-0.9.0 lib/dry/system/importer.rb
dry-system-0.8.1 lib/dry/system/importer.rb
dry-system-0.8.0 lib/dry/system/importer.rb
dry-system-0.7.3 lib/dry/system/importer.rb
dry-system-0.7.2 lib/dry/system/importer.rb
dry-system-0.7.1 lib/dry/system/importer.rb
dry-system-0.7.0 lib/dry/system/importer.rb
dry-system-0.6.0 lib/dry/system/importer.rb
dry-system-0.5.1 lib/dry/system/importer.rb
dry-system-0.5.0 lib/dry/system/importer.rb