Sha256: 0530bf4e238c13ca18cc88e738e0b70147773d5225609a4be329255ad9357af1
Contents?: true
Size: 968 Bytes
Versions: 3
Compression:
Stored size: 968 Bytes
Contents
# frozen_string_literal: true require "batch_loader/executor" class BatchLoader class ExecutorProxy attr_reader :block, :global_executor def initialize(&block) @block = block @block_hash_key = block.source_location @global_executor = BatchLoader::Executor.ensure_current end def add(item:) items_to_load << item end def list_items items_to_load.to_a end def delete(items:) global_executor.items_by_block[@block_hash_key] = items_to_load - items end def load(item:, value:) loaded[item] = value end def loaded_value(item:) loaded[item] end def value_loaded?(item:) loaded.key?(item) end def unload_value(item:) loaded.delete(item) end private def items_to_load global_executor.items_by_block[@block_hash_key] end def loaded global_executor.loaded_values_by_block[@block_hash_key] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
batch-loader-1.0.2 | lib/batch_loader/executor_proxy.rb |
batch-loader-1.0.1 | lib/batch_loader/executor_proxy.rb |
batch-loader-1.0.0 | lib/batch_loader/executor_proxy.rb |