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

28 lines
472 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
class DataList
2020-11-24 15:15:51 +05:30
def initialize(batch_ids, data_fields_hash, klass)
@batch_ids = batch_ids
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
2020-11-24 15:15:51 +05:30
attr_reader :batch_ids, :data_fields_hash, :klass
2020-06-23 00:09:42 +05:30
def columns
data_fields_hash.keys << 'service_id'
end
def values
2020-11-24 15:15:51 +05:30
batch_ids.map do |row|
data_fields_hash.values << row['id']
end
2020-06-23 00:09:42 +05:30
end
end