Sha256: bda39fc2d45a2768e6f889dbddbc819a48d70ce902a3b5e50e58f2ad56fe13af

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class SmartCore::Injection::Locator
  require_relative 'locator/container_proxy'
  require_relative 'locator/dependency'
  require_relative 'locator/factory'

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

  # @param import_path [String]
  # @param container_proxy [SmartCore::Injection::Locator::ContainerProxy]
  # @return [void]
  #
  # @api private
  # @since 0.1.0
  def initialize(import_path, container_proxy)
    @import_path = import_path
    @container_proxy = container_proxy
    @dependency = SmartCore::Injection::Locator::Dependency.new
  end

  # @return [Any]
  #
  # @api private
  # @since 0.1.0
  def resolve_dependency
    dependency.bind { container_proxy.resolve_dependency(import_path) }
  end
  alias_method :bind!, :resolve_dependency

  # @return [Any]
  #
  # @api private
  # @since 0.1.0
  def rebind_dependency
    dependency.rebind { container_proxy.resolve_dependency(import_path) }
  end
  alias_method :rebind!, :rebind_dependency

  private

  # @return [SmartCore::Injection::Locator::Dependency]
  #
  # @api private
  # @since 0.1.0
  attr_reader :dependency

  # @return [SmartCore::Injection::Locator::ContainerProxy]
  #
  # @api private
  # @since 0.1.0
  attr_reader :container_proxy
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smart_injection-0.2.0 lib/smart_core/injection/locator.rb
smart_injection-0.1.0 lib/smart_core/injection/locator.rb
smart_injection-0.0.0.alpha3 lib/smart_core/injection/locator.rb