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

failure.rb « bulk_imports « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44d16618c777d6c7c1496a2433b1c9f6e8c8e610 (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
28
29
30
31
32
33
# frozen_string_literal: true

class BulkImports::Failure < ApplicationRecord
  self.table_name = 'bulk_import_failures'

  belongs_to :entity,
    class_name: 'BulkImports::Entity',
    foreign_key: :bulk_import_entity_id,
    inverse_of: :failures,
    optional: false

  validates :entity, presence: true

  def relation
    pipeline_relation || default_relation
  end

  private

  def pipeline_relation
    klass = pipeline_class.constantize

    return unless klass.ancestors.include?(BulkImports::Pipeline)

    klass.relation
  rescue NameError
    nil
  end

  def default_relation
    pipeline_class.demodulize.chomp('Pipeline').underscore
  end
end