blob: 785f6eea6bf0ba34b013d06bdec1049a4074e462 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 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
|