lib/batch_loader/executor_proxy.rb in batch-loader-0.3.0 vs lib/batch_loader/executor_proxy.rb in batch-loader-1.0.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require "batch_loader/executor"
class BatchLoader
class ExecutorProxy
attr_reader :block, :global_executor
@@ -9,19 +11,19 @@
@block_hash_key = block.source_location
@global_executor = BatchLoader::Executor.ensure_current
end
def add(item:)
- items << item
+ items_to_load << item
end
def list_items
- items.to_a
+ items_to_load.to_a
end
- def delete_items
- global_executor.items_by_block[@block_hash_key] = Set.new
+ def delete(items:)
+ global_executor.items_by_block[@block_hash_key] = items_to_load - items
end
def load(item:, value:)
loaded[item] = value
end
@@ -38,10 +40,10 @@
loaded.delete(item)
end
private
- def items
+ def items_to_load
global_executor.items_by_block[@block_hash_key]
end
def loaded
global_executor.loaded_values_by_block[@block_hash_key]