debian-mirror-gitlab/app/models/data_list.rb
2021-01-03 14:25:43 +05:30

27 lines
458 B
Ruby

# frozen_string_literal: true
class DataList
def initialize(batch, data_fields_hash, klass)
@batch = batch
@data_fields_hash = data_fields_hash
@klass = klass
end
def to_array
[klass, columns, values]
end
private
attr_reader :batch, :data_fields_hash, :klass
def columns
data_fields_hash.keys << 'service_id'
end
def values
batch.map do |record|
data_fields_hash.values << record['id']
end
end
end