debian-mirror-gitlab/app/models/data_list.rb
2020-06-23 00:09:42 +05:30

25 lines
439 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 { |row| data_fields_hash.values << row['id'] }
end
end