debian-mirror-gitlab/app/models/concerns/analytics/cycle_analytics/parentable.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
620 B
Ruby
Raw Normal View History

2023-03-17 16:20:25 +05:30
# frozen_string_literal: true
module Analytics
module CycleAnalytics
module Parentable
extend ActiveSupport::Concern
included do
belongs_to :namespace, class_name: 'Namespace', foreign_key: :group_id, optional: false # rubocop: disable Rails/InverseOf
validate :ensure_namespace_type
def ensure_namespace_type
return if namespace.nil?
return if namespace.is_a?(::Namespaces::ProjectNamespace) || namespace.is_a?(::Group)
errors.add(:namespace, s_('CycleAnalytics|the assigned object is not supported'))
end
end
end
end
end