Sha256: ae72b430d384eda8846599459da232196a74096ad2d4c700aee872d98d1f6513

Contents?: true

Size: 1.31 KB

Versions: 12

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

    # @return [String]
    #
    # @api private
    # @since 0.1.0
    attr_reader :namespace_name

    # @param namespace_name [String, Symbol]
    # @param dependencies_definition [Proc]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def initialize(namespace_name, dependencies_definition)
      SmartCore::Container::KeyGuard.indifferently_accessable_key(namespace_name).tap do |name|
        @namespace_name = name
        @dependencies_definition = dependencies_definition
      end
    end

    # @param registry [SmartCore::Container::Registry]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def call(registry)
      registry.register_namespace(namespace_name, &dependencies_definition)
    end

    # @return [SmartCore::Container::DefinitionDSL::Commands::Definition::Namespace]
    #
    # @api private
    # @since 0.1.0
    def dup
      self.class.new(namespace_name, dependencies_definition)
    end

    private

    # @return [Proc]
    #
    # @api private
    # @since 0.1.0
    attr_reader :dependencies_definition
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
smart_container-0.11.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.10.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.9.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.8.1 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.8.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.7.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.6.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.5.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.4.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.3.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.2.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb
smart_container-0.1.0 lib/smart_core/container/definition_dsl/commands/definition/namespace.rb