class Dry::DependencyInjection::Registry

Public Class Methods

new() click to toggle source
# File lib/dry/dependency_injection/registry.rb, line 7
def initialize
  @_lock = Concurrent::ReentrantReadWriteLock.new
  @_mutex = Concurrent::Synchronization::Lock.new
end

Public Instance Methods

call(container, key, item, _options) click to toggle source
# File lib/dry/dependency_injection/registry.rb, line 12
def call(container, key, item, _options)
  key = key.to_s.dup.freeze
  @_mutex.synchronize do
    if container.key?(key)
      raise Dry::Container::Error, "There is already an item registered with the key #{key.inspect}"
    end

    container[key] = Item.new(@_lock, item)
  end
end