gitlab-org--gitlab-foss/app/models/data_list.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
627 B
Ruby
Raw Normal View History

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