Module: Serega::SeregaPlugins::Batch::SeregaBatchLoader::InstanceMethods

Included in:
Serega::SeregaPlugins::Batch::SeregaBatchLoader
Defined in:
lib/serega/plugins/batch/lib/loader.rb

Overview

Batch Loader instance methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#object_serializerSerega::SeregaObjectSerializer (readonly)



19
20
21
# File 'lib/serega/plugins/batch/lib/loader.rb', line 19

def object_serializer
  @object_serializer
end

#pointSerega::SeregaMapPoint (readonly)



16
17
18
# File 'lib/serega/plugins/batch/lib/loader.rb', line 16

def point
  @point
end

Instance Method Details

#initialize(object_serializer, point) ⇒ Serega::SeregaPlugins::Batch::SeregaBatchLoader

Initializes new SeregaBatchLoader



29
30
31
32
# File 'lib/serega/plugins/batch/lib/loader.rb', line 29

def initialize(object_serializer, point)
  @object_serializer = object_serializer
  @point = point
end

#loadvoid

This method returns an undefined value.

Loads this batch and assigns values to remembered containers



51
52
53
54
55
56
57
58
59
# File 'lib/serega/plugins/batch/lib/loader.rb', line 51

def load
  keys_values = keys_values()

  each_key do |key, container|
    value = keys_values.fetch(key) { point.batch.default_value }
    final_value = object_serializer.__send__(:final_value, value, point)
    object_serializer.__send__(:attach_final_value, final_value, point, container)
  end
end

#remember(key, container) ⇒ void

This method returns an undefined value.

Remembers key and hash container where value for this key must be inserted

Parameters:

  • key (Object)

    key that identifies batch loaded objects

  • container (Hash)

    container where batch loaded objects must be attached



42
43
44
# File 'lib/serega/plugins/batch/lib/loader.rb', line 42

def remember(key, container)
  (keys[key] ||= []) << container
end