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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-07-23 17:51:13 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2019-07-30 15:52:54 +0300
commit916183a7fd63f772a8493c9ac782b465503f9d13 (patch)
tree7835e5e3e0c3b8b63be81b7f44e5221cd0770e0e /config/initializers/0_inject_enterprise_edition_module.rb
parent5a221665bedc2366b30b2a2b0f777ead657c6143 (diff)
Add methods for injecting EE modules
This adds the methods prepend_if_ee, extend_if_ee, and include_if_ee that can be used to inject EE specific modules in EE. These methods are exposed as an initializer that is loaded as soon as possible. For tests that use fast_spec_helper.rb we must load this initializer manually, as the Rails environment is not loaded. This is not the most pretty setup, but unfortunately there is no alternative that we can use.
Diffstat (limited to 'config/initializers/0_inject_enterprise_edition_module.rb')
-rw-r--r--config/initializers/0_inject_enterprise_edition_module.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/config/initializers/0_inject_enterprise_edition_module.rb b/config/initializers/0_inject_enterprise_edition_module.rb
new file mode 100644
index 00000000000..4b21732e179
--- /dev/null
+++ b/config/initializers/0_inject_enterprise_edition_module.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module InjectEnterpriseEditionModule
+ def prepend_if_ee(constant)
+ prepend(constant.constantize) if Gitlab.ee?
+ 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)