summaryrefslogtreecommitdiff
path: root/config/initializers/0_inject_enterprise_edition_module.rb
blob: b3ebb44ef255f7b9009435a84baaaf0114537d28 (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
# frozen_string_literal: true

require 'active_support/inflector'

module InjectEnterpriseEditionModule
  def prepend_if_ee(constant, with_descendants: false)
    return unless Gitlab.ee?

    ee_module = constant.constantize
    prepend(ee_module)

    if with_descendants
      descendants.each { |descendant| descendant.prepend(ee_module) }
    end
  end

  def extend_if_ee(constant)
    extend(constant.constantize) if Gitlab.ee?
  end

  def include_if_ee(constant)
    include(constant.constantize) if Gitlab.ee?
  end
end

Module.prepend(InjectEnterpriseEditionModule)