Sha256: 4492d45d6a06f017c37b5cd3ef35f99a32d24a107ce87abcd8c626c1c97ce750

Contents?: true

Size: 718 Bytes

Versions: 4

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Core
    class Container
      class Item
        # Factory for create an Item to register inside of container
        #
        # @api public
        class Factory
          # Creates an Item Memoizable or Callable
          # @param [Mixed] item
          # @param [Hash] options
          #
          # @raise [Dry::Core::Container::Error]
          #
          # @return [Dry::Core::Container::Item::Base]
          def call(item, options = {})
            if options[:memoize]
              Item::Memoizable.new(item, options)
            else
              Item::Callable.new(item, options)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-core-1.1.0 lib/dry/core/container/item/factory.rb
dry-core-1.0.2 lib/dry/core/container/item/factory.rb
dry-core-1.0.1 lib/dry/core/container/item/factory.rb
dry-core-1.0.0 lib/dry/core/container/item/factory.rb