2020-05-20 14:08:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DataList
|
2020-09-29 11:10:08 -04:00
|
|
|
def initialize(batch, data_fields_hash, klass)
|
|
|
|
@batch = batch
|
2020-05-20 14:08:00 -04:00
|
|
|
@data_fields_hash = data_fields_hash
|
|
|
|
@klass = klass
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_array
|
|
|
|
[klass, columns, values]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-09-29 11:10:08 -04:00
|
|
|
attr_reader :batch, :data_fields_hash, :klass
|
2020-05-20 14:08:00 -04:00
|
|
|
|
|
|
|
def columns
|
|
|
|
data_fields_hash.keys << 'service_id'
|
|
|
|
end
|
|
|
|
|
|
|
|
def values
|
2020-09-29 11:10:08 -04:00
|
|
|
batch.map do |record|
|
|
|
|
data_fields_hash.values << record['id']
|
2020-09-15 11:10:08 -04:00
|
|
|
end
|
2020-05-20 14:08:00 -04:00
|
|
|
end
|
|
|
|
end
|