Sha256: 7cdaa1adae0d1299845f178dc43cf40b3510db7d3aef18c453133c9d48a887e3

Contents?: true

Size: 810 Bytes

Versions: 6

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

require 'dry/auto_inject/strategies'

module Dry
  module AutoInject
    class Injector < BasicObject
      # @api private
      attr_reader :container

      # @api private
      attr_reader :strategy

      # @api private
      attr_reader :builder

      # @api private
      def initialize(container, strategy, builder:)
        @container = container
        @strategy = strategy
        @builder = builder
      end

      def [](*dependency_names)
        strategy.new(container, *dependency_names)
      end

      def respond_to?(name, include_private = false)
        Injector.instance_methods.include?(name) || builder.respond_to?(name)
      end

      private

      def method_missing(name, *args, &block)
        builder.__send__(name)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-auto_inject-0.8.0 lib/dry/auto_inject/injector.rb
dry-auto_inject-0.7.0 lib/dry/auto_inject/injector.rb
dry-auto_inject-0.6.1 lib/dry/auto_inject/injector.rb
dry-auto_inject-0.6.0 lib/dry/auto_inject/injector.rb
dry-auto_inject-0.5.0 lib/dry/auto_inject/injector.rb
dry-auto_inject-0.4.6 lib/dry/auto_inject/injector.rb