2020-05-20 14:08:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ServiceList
|
2020-09-15 11:10:08 -04:00
|
|
|
def initialize(batch_ids, service_hash, association)
|
2020-09-08 11:08:41 -04:00
|
|
|
@batch_ids = batch_ids
|
2020-05-20 14:08:00 -04:00
|
|
|
@service_hash = service_hash
|
2020-09-15 11:10:08 -04:00
|
|
|
@association = association
|
2020-05-20 14:08:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_array
|
|
|
|
[Service, columns, values]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-09-15 11:10:08 -04:00
|
|
|
attr_reader :batch_ids, :service_hash, :association
|
2020-05-20 14:08:00 -04:00
|
|
|
|
|
|
|
def columns
|
2020-09-15 11:10:08 -04:00
|
|
|
(service_hash.keys << "#{association}_id")
|
2020-05-20 14:08:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def values
|
2020-09-15 11:10:08 -04:00
|
|
|
batch_ids.map do |id|
|
|
|
|
(service_hash.values << id)
|
2020-05-20 14:08:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|