debian-mirror-gitlab/app/models/bulk_imports/failure.rb

34 lines
660 B
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# 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
2022-11-25 23:54:43 +05:30
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
2021-02-22 17:27:13 +05:30
end