lib/dry/container/mixin.rb in dry-container-0.3.0 vs lib/dry/container/mixin.rb in dry-container-0.3.1
- old
+ new
@@ -33,11 +33,11 @@
setting :registry, ::Dry::Container::Registry.new
setting :resolver, ::Dry::Container::Resolver.new
setting :namespace_separator, '.'
- @_container = ::ThreadSafe::Hash.new
+ @_container = ::Concurrent::Hash.new
def self.inherited(subclass)
subclass.instance_variable_set(:@_container, @_container.dup)
super
end
@@ -54,11 +54,11 @@
setting :namespace_separator, '.'
attr_reader :_container
def initialize(*args, &block)
- @_container = ::ThreadSafe::Hash.new
+ @_container = ::Concurrent::Hash.new
super(*args, &block)
end
def config
self.class.config
@@ -103,10 +103,22 @@
#
# @api public
def resolve(key)
config.resolver.call(_container, key)
end
- alias [] resolve
+
+ # Resolve an item from the container
+ #
+ # @param [Mixed] key
+ # The key for the item you wish to resolve
+ #
+ # @return [Mixed]
+ #
+ # @api public
+ # @see Dry::Container::Mixin#resolve
+ def [](key)
+ resolve(key)
+ end
# Merge in the items of the other container
#
# @param [Dry::Container] other
# The other container to merge in