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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/integrations/integration_list.rb')
-rw-r--r--app/models/integrations/integration_list.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/integrations/integration_list.rb b/app/models/integrations/integration_list.rb
new file mode 100644
index 00000000000..ab03e5c0e0a
--- /dev/null
+++ b/app/models/integrations/integration_list.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Integrations
+ class IntegrationList
+ def initialize(batch, integration_hash, association)
+ @batch = batch
+ @integration_hash = integration_hash
+ @association = association
+ end
+
+ def to_array
+ [Integration, columns, values]
+ end
+
+ private
+
+ attr_reader :batch, :integration_hash, :association
+
+ def columns
+ integration_hash.keys << "#{association}_id"
+ end
+
+ def values
+ batch.select(:id).map do |record|
+ integration_hash.values << record.id
+ end
+ end
+ end
+end