Welcome to mirror list, hosted at ThFree Co, Russian Federation.

service_list.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa3760f0c561aab073a84d1536bfdbaaf6202711 (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, service_hash, extra_hash = {})
    @batch = batch
    @service_hash = service_hash
    @extra_hash = extra_hash
  end

  def to_array
    [Service, columns, values]
  end

  private

  attr_reader :batch, :service_hash, :extra_hash

  def columns
    (service_hash.keys << 'project_id') + extra_hash.keys
  end

  def values
    batch.map do |project_id|
      (service_hash.values << project_id) + extra_hash.values
    end
  end
end