debian-mirror-gitlab/app/models/data_list.rb

28 lines
458 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
class DataList
2021-01-03 14:25:43 +05:30
def initialize(batch, data_fields_hash, klass)
@batch = batch
2020-06-23 00:09:42 +05:30
@data_fields_hash = data_fields_hash
@klass = klass
end
def to_array
[klass, columns, values]
end
private
2021-01-03 14:25:43 +05:30
attr_reader :batch, :data_fields_hash, :klass
2020-06-23 00:09:42 +05:30
def columns
data_fields_hash.keys << 'service_id'
end
def values
2021-01-03 14:25:43 +05:30
batch.map do |record|
data_fields_hash.values << record['id']
2020-11-24 15:15:51 +05:30
end
2020-06-23 00:09:42 +05:30
end
end