summaryrefslogtreecommitdiff
path: root/app/models/service_list.rb
blob: 9cbc5e680591ad9bd7500ec4e05a764a40aefce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

class ServiceList
  def initialize(batch_ids, service_hash, association)
    @batch_ids = batch_ids
    @service_hash = service_hash
    @association = association
  end

  def to_array
    [Service, columns, values]
  end

  private

  attr_reader :batch_ids, :service_hash, :association

  def columns
    (service_hash.keys << "#{association}_id")
  end

  def values
    batch_ids.map do |id|
      (service_hash.values << id)
    end
  end
end