Class: BatchLoader::ExecutorProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_loader/executor_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ExecutorProxy

Returns a new instance of ExecutorProxy.



9
10
11
12
13
# File 'lib/batch_loader/executor_proxy.rb', line 9

def initialize(&block)
  @block = block
  @block_hash_key = block.source_location
  @global_executor = BatchLoader::Executor.ensure_current
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/batch_loader/executor_proxy.rb', line 7

def block
  @block
end

#global_executorObject (readonly)

Returns the value of attribute global_executor.



7
8
9
# File 'lib/batch_loader/executor_proxy.rb', line 7

def global_executor
  @global_executor
end

Instance Method Details

#add(item:) ⇒ Object



15
16
17
# File 'lib/batch_loader/executor_proxy.rb', line 15

def add(item:)
  items_to_load << item
end

#delete(items:) ⇒ Object



23
24
25
# File 'lib/batch_loader/executor_proxy.rb', line 23

def delete(items:)
  global_executor.items_by_block[@block_hash_key] = items_to_load - items
end

#list_itemsObject



19
20
21
# File 'lib/batch_loader/executor_proxy.rb', line 19

def list_items
  items_to_load.to_a
end

#load(item:, value:) ⇒ Object



27
28
29
# File 'lib/batch_loader/executor_proxy.rb', line 27

def load(item:, value:)
  loaded[item] = value
end

#loaded_value(item:) ⇒ Object



31
32
33
# File 'lib/batch_loader/executor_proxy.rb', line 31

def loaded_value(item:)
  loaded[item]
end

#unload_value(item:) ⇒ Object



39
40
41
# File 'lib/batch_loader/executor_proxy.rb', line 39

def unload_value(item:)
  loaded.delete(item)
end

#value_loaded?(item:) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/batch_loader/executor_proxy.rb', line 35

def value_loaded?(item:)
  loaded.key?(item)
end