Module: Serega::SeregaBatch::AttributeLoader::InstanceMethods
- Included in:
- Serega::SeregaBatch::AttributeLoader
- Defined in:
- lib/serega/batch/attribute_loader.rb
Overview
Instance methods for AttributeLoader
Instance Method Summary collapse
- #initialize(point) ⇒ Object
-
#load_all(context) ⇒ void
Loads serialized values for all stored objects for current attribute.
-
#store(object, attacher) ⇒ void
Stores object with attacher to find and attach attribute values in batch later.
Instance Method Details
#initialize(point) ⇒ Object
13 14 15 16 17 |
# File 'lib/serega/batch/attribute_loader.rb', line 13 def initialize(point) @point = point @objects = [] @serialized_object_attachers = [] end |
#load_all(context) ⇒ void
This method returns an undefined value.
Loads serialized values for all stored objects for current attribute
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/serega/batch/attribute_loader.rb', line 31 def load_all(context) batches = {} serializer_class = point.class.serializer_class point.batch_loaders.each do |batch_loader_name| batches[batch_loader_name] ||= load_one(serializer_class, batch_loader_name, context) end serialized_object_attachers.each do |object, attacher| attacher.call(object, batches) end end |
#store(object, attacher) ⇒ void
This method returns an undefined value.
Stores object with attacher to find and attach attribute values in batch later.
23 24 25 26 |
# File 'lib/serega/batch/attribute_loader.rb', line 23 def store(object, attacher) objects << object serialized_object_attachers << [object, attacher] end |