debian-mirror-gitlab/app/models/label_link.rb
2021-06-08 01:23:25 +05:30

15 lines
572 B
Ruby

# frozen_string_literal: true
class LabelLink < ApplicationRecord
include BulkInsertSafe
include Importable
belongs_to :target, polymorphic: true, inverse_of: :label_links # rubocop:disable Cop/PolymorphicAssociations
belongs_to :label
validates :target, presence: true, unless: :importing?
validates :label, presence: true, unless: :importing?
scope :for_target, -> (target_id, target_type) { where(target_id: target_id, target_type: target_type) }
scope :with_remove_on_close_labels, -> { joins(:label).where(labels: { remove_on_close: true }) }
end