2020-06-23 00:09:42 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ServiceList
|
2020-11-24 15:15:51 +05:30
|
|
|
def initialize(batch_ids, service_hash, association)
|
|
|
|
@batch_ids = batch_ids
|
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
|
|
|
|
[Service, columns, values]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
attr_reader :batch_ids, :service_hash, :association
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
def columns
|
2020-11-24 15:15:51 +05:30
|
|
|
(service_hash.keys << "#{association}_id")
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def values
|
2020-11-24 15:15:51 +05:30
|
|
|
batch_ids.map do |id|
|
|
|
|
(service_hash.values << id)
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|