Sha256: 33530778be03805238c8fbbf99fcc754fd58a35818a14cb309a3e92a3eeca073

Contents?: true

Size: 546 Bytes

Versions: 20

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

class BatchLoader
  class Executor
    NAMESPACE = :batch_loader

    def self.ensure_current
      Thread.current[NAMESPACE] ||= new
    end

    def self.current
      Thread.current[NAMESPACE]
    end

    def self.clear_current
      Thread.current[NAMESPACE] = nil
    end

    attr_reader :items_by_block, :loaded_values_by_block

    def initialize
      @items_by_block = Hash.new { |hash, key| hash[key] = Set.new }
      @loaded_values_by_block = Hash.new { |hash, key| hash[key] = {} }
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
batch-loader-2.0.5 lib/batch_loader/executor.rb
batch-loader-2.0.4 lib/batch_loader/executor.rb
batch-loader-2.0.3 lib/batch_loader/executor.rb
batch-loader-2.0.2 lib/batch_loader/executor.rb
batch-loader-2.0.1 lib/batch_loader/executor.rb
batch-loader-2.0.0 lib/batch_loader/executor.rb
batch-loader-1.5.0 lib/batch_loader/executor.rb
batch-loader-1.4.1 lib/batch_loader/executor.rb
batch-loader-1.4.0 lib/batch_loader/executor.rb
batch-loader-1.3.0 lib/batch_loader/executor.rb
batch-loader-1.2.2 lib/batch_loader/executor.rb
batch-loader-1.2.1 lib/batch_loader/executor.rb
batch-loader-1.2.0 lib/batch_loader/executor.rb
batch-loader-1.1.1 lib/batch_loader/executor.rb
batch-loader-1.1.0 lib/batch_loader/executor.rb
batch-loader-1.0.4 lib/batch_loader/executor.rb
batch-loader-1.0.3 lib/batch_loader/executor.rb
batch-loader-1.0.2 lib/batch_loader/executor.rb
batch-loader-1.0.1 lib/batch_loader/executor.rb
batch-loader-1.0.0 lib/batch_loader/executor.rb