class Dry::Core::Container::Registry
@api public
Default registry for registering items with the container
def call(container, key, item, options)
- Api: - public
Returns:
-
(Mixed)
-
Raises:
-
(Dry::Core::Container::KeyError)
-
Options Hash:
(**options)
-
:call
(Symbol
) --
Parameters:
-
options
(Hash
) -- -
item
(Mixed
) -- -
key
(Mixed
) -- -
container
(Concurrent::Hash
) --
def call(container, key, item, options) key = key.to_s.dup.freeze @_mutex.synchronize do if container.key?(key) raise KeyError, "There is already an item registered with the key #{key.inspect}" end container[key] = factory.call(item, options) end end
def factory
- Api: - private
def factory @factory ||= Container::Item::Factory.new end
def initialize
- Private: -
def initialize @_mutex = ::Mutex.new end