2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'active_support/inflector'
|
|
|
|
|
|
|
|
module InjectEnterpriseEditionModule
|
2019-12-04 20:38:33 +05:30
|
|
|
def prepend_if_ee(constant, with_descendants: false)
|
|
|
|
return unless Gitlab.ee?
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
prepend_module(constant.constantize, with_descendants)
|
2019-10-12 21:52:04 +05:30
|
|
|
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
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
def prepend_if_jh(constant, with_descendants: false)
|
|
|
|
return unless Gitlab.jh?
|
|
|
|
|
|
|
|
prepend_module(constant.constantize, with_descendants)
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
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
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
Module.prepend(InjectEnterpriseEditionModule)
|