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
|
|
|
|
[Service, columns, values]
|
|
|
|
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
|