Method: Cequel::Record::LazyRecordCollection#initialize

Defined in:
lib/cequel/record/lazy_record_collection.rb

#initialize(record_set) ⇒ LazyRecordCollection

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LazyRecordCollection.

Parameters:

  • record_set (RecordSet)

    record set representing the records in this collection

Since:

  • 1.0.0



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cequel/record/lazy_record_collection.rb', line 29

def initialize(record_set)
  fail ArgumentError if record_set.nil?
  @record_set = record_set

  exploded_key_attributes = [{}].tap do |all_key_attributes|
    key_columns.zip(scoped_key_values) do |column, values|
      all_key_attributes.replace(Array(values).flat_map do |value|
        all_key_attributes.map do |key_attributes|
          key_attributes.merge(column.name => value)
        end
      end)
    end
  end

  unloaded_records = exploded_key_attributes.map do |key_attributes|
    record_set.target_class.new_empty(key_attributes, self)
  end

  super(unloaded_records)
end