lib/dry/container/mixin.rb in dry-container-0.2.0 vs lib/dry/container/mixin.rb in dry-container-0.2.1
- old
+ new
@@ -24,21 +24,19 @@
#
# @api public
module Mixin
# @private
def self.extended(base)
+ attr_reader :_container
+
base.class_eval do
extend ::Dry::Configurable
setting :registry, Registry.new
setting :resolver, Resolver.new
@_container = ThreadSafe::Cache.new
-
- class << self
- attr_reader :_container
- end
end
end
# @private
def self.included(base)
base.class_eval do
@@ -95,19 +93,9 @@
#
# @api public
def resolve(key)
config.resolver.call(_container, key)
end
- # Resolve an item from the container
- #
- # @param [Mixed] key
- # The key for the item you wish to resolve
- #
- # @return [Mixed]
- #
- # @api public
- def [](key)
- resolve(key)
- end
+ alias_method :[], :resolve
end
end
end