Sha256: e89375791437e93da04e6897b4a2a22bd7ac1fba031ed7472524885e2ee153b2

Contents?: true

Size: 697 Bytes

Versions: 5

Compression:

Stored size: 697 Bytes

Contents

module Dry
  class Container
    # Default resolver for resolving items from container
    #
    # @api public
    class Resolver
      # Resolve an item from the container
      #
      # @param [ThreadSafe::Hash] container
      #   The container
      # @param [Mixed] key
      #   The key for the item you wish to resolve
      #
      # @raise [Dry::Conainer::Error]
      #   If the given key is not registered with the container
      #
      # @return [Mixed]
      #
      # @api public
      def call(container, key)
        item = container.fetch(key) do
          fail Error, "Nothing registered with the key #{key.inspect}"
        end

        item.call
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-container-0.2.4 lib/dry/container/resolver.rb
dry-container-0.2.3 lib/dry/container/resolver.rb
dry-container-0.2.2 lib/dry/container/resolver.rb
dry-container-0.2.1 lib/dry/container/resolver.rb
dry-container-0.2.0 lib/dry/container/resolver.rb