Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8ccd8070
Commit
8ccd8070
authored
Jul 30, 2019
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added docs for the new EE injection methods
parent
1112fec4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
doc/development/ee_features.md
doc/development/ee_features.md
+18
-14
No files found.
doc/development/ee_features.md
View file @
8ccd8070
...
...
@@ -125,11 +125,11 @@ This also applies to views.
### EE features based on CE features
For features that build on existing CE features, write a module in the
`EE`
namespace and
`prepend`
it in the CE class, on the last line of the file that
the
class resides in. This makes conflicts less likely to happen during CE to EE
merges because only one line is added to the CE class - the
`prepend`
line. For
example, to prepend a module into the
`User`
class you would use the following
approach:
namespace and
inject it in the CE class, on the last line of the file that the
class resides in. This makes conflicts less likely to happen during CE to EE
merges because only one line is added to the CE class - the
line that injects
the module. For example, to prepend a module into the
`User`
class you would use
the following
approach:
```
ruby
class
User
<
ActiveRecord
::
Base
...
...
@@ -139,6 +139,10 @@ end
User
.
prepend_if_ee
(
'EE::User'
)
```
Do not use methods such as
`prepend`
,
`extend`
, and
`include`
. Instead, use
`prepend_if_ee`
,
`extend_if_ee`
, or
`include_if_ee`
. These methods take a
_String_
containing the full module name as the argument, not the module itself.
Since the module would require an
`EE`
namespace, the file should also be
put in an
`ee/`
sub-directory. For example, we want to extend the user model
in EE, so we have a module called
`::EE::User`
put inside
...
...
@@ -504,9 +508,9 @@ EE-specific LDAP classes in `ee/lib/ee/gitlab/ldap`.
### Code in `lib/api/`
It can be very tricky to extend EE features by a single line of
`prepend`
,
and for each different
[
Grape
](
https://github.com/ruby-grape/grape
)
feature,
we
might need different strategies to extend it. To apply different strategies
It can be very tricky to extend EE features by a single line of
`prepend
_if_ee
`
,
and for each different
[
Grape
](
https://github.com/ruby-grape/grape
)
feature,
we
might need different strategies to extend it. To apply different strategies
easily, we would use
`extend ActiveSupport::Concern`
in the EE module.
Put the EE module files following
...
...
@@ -543,12 +547,12 @@ constants.
We can define
`params`
and utilize
`use`
in another
`params`
definition to
include params defined in EE. However, we need to define the "interface" first
in CE in order for EE to override it. We don't have to do this in other places
due to
`prepend
`
, but Grape is complex internally and we couldn't easily do
that, so we'll follow regular object-oriented practices that we define the
due to
`prepend
_if_ee`
, but Grape is complex internally and we couldn't easily
do
that, so we'll follow regular object-oriented practices that we define the
interface first here.
For example, suppose we have a few more optional params for EE. We can move the
params out of the
`Grape::API`
class to a helper module, so we can
`prepend`
it
params out of the
`Grape::API`
class to a helper module, so we can
inject
it
before it would be used in the class.
```
ruby
...
...
@@ -717,8 +721,8 @@ Sometimes we need to use different arguments for a particular API route, and we
can't easily extend it with an EE module because Grape has different context in
different blocks. In order to overcome this, we need to move the data to a class
method that resides in a separate module or class. This allows us to extend that
module or class before its data is used, without having to place a
`prepend`
in
the middle of CE code.
module or class before its data is used, without having to place a
`prepend_if_ee`
in
the middle of CE code.
For example, in one place we need to pass an extra argument to
`at_least_one_of`
so that the API could consider an EE-only argument as the
...
...
@@ -789,7 +793,7 @@ class Identity < ActiveRecord::Base
[
:provider
]
end
prepend
EE
::
Identity
prepend
_if_ee
(
'EE::Identity'
)
validates
:extern_uid
,
allow_blank:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment