Class: Serega::SeregaBatch::AttributeLoaders
- Inherits:
-
Object
- Object
- Serega::SeregaBatch::AttributeLoaders
- Defined in:
- lib/serega/batch/attribute_loaders.rb
Overview
Batch loaders
Remembers data required to batch load all attributes
Instance Method Summary collapse
-
#initialize ⇒ AttributeLoaders
constructor
Initializes new batch loaders.
-
#load_all(context) ⇒ Object
Loads all registered batches and removes them from registered list.
-
#remember(point, object, attacher) ⇒ void
Remembers data for batch seryalization:.
Constructor Details
#initialize ⇒ AttributeLoaders
Initializes new batch loaders
16 17 18 19 |
# File 'lib/serega/batch/attribute_loaders.rb', line 16 def initialize @point_batch_loaders = [] @point_index = {}.compare_by_identity end |
Instance Method Details
#load_all(context) ⇒ Object
Loads all registered batches and removes them from registered list
44 45 46 47 48 |
# File 'lib/serega/batch/attribute_loaders.rb', line 44 def load_all(context) point_batch_loaders.each do |point_batch_loader| point_batch_loader.load_all(context) end end |
#remember(point, object, attacher) ⇒ void
This method returns an undefined value.
Remembers data for batch seryalization:
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/serega/batch/attribute_loaders.rb', line 28 def remember(point, object, attacher) point_batch_loader = point_index[point] unless point_batch_loader serializer_class = point.class.serializer_class point_batch_loader = serializer_class::SeregaBatchAttributeLoader.new(point) point_batch_loaders << point_batch_loader point_index[point] = point_batch_loader end point_batch_loader.store(object, attacher) end |