Sha256: 32b83bc5576d31eb9b933530d28166fecaf74388519fa1fe024769273bd39f54

Contents?: true

Size: 513 Bytes

Versions: 19

Compression:

Stored size: 513 Bytes

Contents

# frozen_string_literal: true

module N1Loader
  # The class is used for storing collections of loaders for elements per set of arguments.
  class LoaderCollection
    attr_reader :loader_class, :elements

    def initialize(loader_class, elements)
      @loader_class = loader_class
      @elements = elements
    end

    def with(**args)
      loader = loader_class.new(elements, **args)

      loaders[loader.cache_key] ||= loader
    end

    private

    def loaders
      @loaders ||= {}
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
n1_loader-1.7.4 lib/n1_loader/core/loader_collection.rb
n1_loader-1.7.3 lib/n1_loader/core/loader_collection.rb
n1_loader-1.7.2 lib/n1_loader/core/loader_collection.rb
n1_loader-1.7.1 lib/n1_loader/core/loader_collection.rb
n1_loader-1.7.0 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.6 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.5 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.4 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.3 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.2 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.1 lib/n1_loader/core/loader_collection.rb
n1_loader-1.6.0 lib/n1_loader/core/loader_collection.rb
n1_loader-1.5.1 lib/n1_loader/core/loader_collection.rb
n1_loader-1.5.0 lib/n1_loader/core/loader_collection.rb
n1_loader-1.4.4 lib/n1_loader/core/loader_collection.rb
n1_loader-1.4.3 lib/n1_loader/core/loader_collection.rb
n1_loader-1.4.2 lib/n1_loader/core/loader_collection.rb
n1_loader-1.4.1 lib/n1_loader/core/loader_collection.rb
n1_loader-1.4.0 lib/n1_loader/core/loader_collection.rb