Class: BatchLoader::ExecutorProxy
- Inherits:
-
Object
- Object
- BatchLoader::ExecutorProxy
- Defined in:
- lib/batch_loader/executor_proxy.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#global_executor ⇒ Object
readonly
Returns the value of attribute global_executor.
Instance Method Summary collapse
- #add(item:) ⇒ Object
- #delete(items:) ⇒ Object
-
#initialize(&block) ⇒ ExecutorProxy
constructor
A new instance of ExecutorProxy.
- #list_items ⇒ Object
- #load(item:, value:) ⇒ Object
- #loaded_value(item:) ⇒ Object
- #unload_value(item:) ⇒ Object
- #value_loaded?(item:) ⇒ Boolean
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/batch_loader/executor_proxy.rb', line 7 def block @block end |
#global_executor ⇒ Object (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_items ⇒ Object
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
35 36 37 |
# File 'lib/batch_loader/executor_proxy.rb', line 35 def value_loaded?(item:) loaded.key?(item) end |