Welcome to mirror list, hosted at ThFree Co, Russian Federation.

0_inject_enterprise_edition_module.rb « initializers « config - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7478727f869e80f8403208663a9f4ba539e74a25 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require 'active_support/inflector'

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

    prepend_module(constant.constantize, with_descendants)
  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

  def prepend_ee_mod(with_descendants: false)
    return unless Gitlab.ee?

    prepend_module(ee_module, with_descendants)
  end

  def extend_ee_mod
    extend(ee_module) if Gitlab.ee?
  end

  def include_ee_mod
    include(ee_module) if Gitlab.ee?
  end

  private

  def prepend_module(mod, with_descendants)
    prepend(mod)

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

  def ee_module
    ::EE.const_get(name, false)
  end
end

Module.prepend(InjectEnterpriseEditionModule)