Commit 3742c587 authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Introduce (prepend|extend|include)_ee_mod helper methods

These methods will automatically find the related EE module for the
module/class and will use it. The other key difference is, these new
methods are using the `const_get` instead of the `String#constantize`.
parent 04f30657
......@@ -6,12 +6,7 @@ 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
prepend_module(constant.constantize, with_descendants)
end
def extend_if_ee(constant)
......@@ -21,6 +16,34 @@ module InjectEnterpriseEditionModule
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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment