Sha256: c9cd3b9f3c8cdba61c747bc3279d99b3b96eb590591cc289bf67833e07cc12dd

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

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
        self
      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

16 entries across 16 versions & 1 rubygems

Version Path
dry-system-0.22.0 lib/dry/system/importer.rb
dry-system-0.21.0 lib/dry/system/importer.rb
dry-system-0.20.0 lib/dry/system/importer.rb
dry-system-0.19.2 lib/dry/system/importer.rb
dry-system-0.18.2 lib/dry/system/importer.rb
dry-system-0.19.1 lib/dry/system/importer.rb
dry-system-0.19.0 lib/dry/system/importer.rb
dry-system-0.18.1 lib/dry/system/importer.rb
dry-system-0.18.0 lib/dry/system/importer.rb
dry-system-0.17.0 lib/dry/system/importer.rb
dry-system-0.15.0 lib/dry/system/importer.rb
dry-system-0.14.1 lib/dry/system/importer.rb
dry-system-0.14.0 lib/dry/system/importer.rb
dry-system-0.13.2 lib/dry/system/importer.rb
dry-system-0.13.1 lib/dry/system/importer.rb
dry-system-0.13.0 lib/dry/system/importer.rb