1
# frozen_string_literal: true
5
NAMESPACE = :batch_loader
7
def self.ensure_current
8
Thread.current[NAMESPACE] ||= new
12
Thread.current[NAMESPACE]
15
def self.clear_current
16
Thread.current[NAMESPACE] = nil
19
attr_reader :items_by_block, :loaded_values_by_block
22
@items_by_block = Hash.new { |hash, key| hash[key] = Set.new }
23
@loaded_values_by_block = Hash.new { |hash, key| hash[key] = {} }