Sha256: 208272277e2651492aff4b547a8a899ff928d685a166e9305a1fc59290ccbc5d

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module SmartCore::Container::DefinitionDSL::Commands::Instantiation
  # @api private
  # @since 0.1.0
  class Compose < SmartCore::Container::DefinitionDSL::Commands::Base
    # @since 0.1.0
    self.inheritable = true

    # @param container_klass [Class<SmartCore::Container>]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def initialize(container_klass)
      raise(
        SmartCore::ArgumentError,
        'Container class should be a subtype of Quantum::Container'
      ) unless container_klass < SmartCore::Container

      @container_klass = container_klass
    end

    # @param registry [SmartCore::Container::Registry]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def call(registry)
      SmartCore::Container::RegistryBuilder.build_state(
        container_klass, registry, ignored_commands: [
          SmartCore::Container::DefinitionDSL::Commands::Instantiation::FreezeState
        ]
      )
    end

    # @return [SmartCore::Container::DefinitionDSL::Commands::Instantiation::Compose]
    #
    # @api private
    # @since 0.1.0
    def dup
      self.class.new(container_klass)
    end

    private

    # @return [Class<SmartCore::Container>]
    #
    # @api private
    # @since 0.1.0
    attr_reader :container_klass
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_container-0.1.0 lib/smart_core/container/definition_dsl/commands/instantiation/compose.rb