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

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

28 lines
483 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
class ServiceList
2021-01-03 14:25:43 +05:30
def initialize(batch, service_hash, association)
@batch = batch
2020-06-23 00:09:42 +05:30
@service_hash = service_hash
2020-11-24 15:15:51 +05:30
@association = association
2020-06-23 00:09:42 +05:30
end
def to_array
2021-06-08 01:23:25 +05:30
[Integration, columns, values]
2020-06-23 00:09:42 +05:30
end
private
2021-01-03 14:25:43 +05:30
attr_reader :batch, :service_hash, :association
2020-06-23 00:09:42 +05:30
def columns
2021-01-03 14:25:43 +05:30
service_hash.keys << "#{association}_id"
2020-06-23 00:09:42 +05:30
end
def values
2021-01-03 14:25:43 +05:30
batch.select(:id).map do |record|
service_hash.values << record.id
2020-06-23 00:09:42 +05:30
end
end
end