Class: BatchLoader::Executor

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

Constant Summary collapse

NAMESPACE =
:batch_loader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExecutor

Returns a new instance of Executor.



21
22
23
24
# File 'lib/batch_loader/executor.rb', line 21

def initialize
  @items_by_block = Hash.new { |hash, key| hash[key] = Set.new }
  @loaded_values_by_block = Hash.new { |hash, key| hash[key] = {} }
end

Instance Attribute Details

#items_by_blockObject (readonly)

Returns the value of attribute items_by_block.



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

def items_by_block
  @items_by_block
end

#loaded_values_by_blockObject (readonly)

Returns the value of attribute loaded_values_by_block.



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

def loaded_values_by_block
  @loaded_values_by_block
end

Class Method Details

.clear_currentObject



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

def self.clear_current
  Thread.current[NAMESPACE] = nil
end

.currentObject



11
12
13
# File 'lib/batch_loader/executor.rb', line 11

def self.current
  Thread.current[NAMESPACE]
end

.ensure_currentObject



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

def self.ensure_current
  Thread.current[NAMESPACE] ||= new
end