summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2019-05-27 15:53:20 +0000
committerLin Jen-Shin <godfat@godfat.org>2019-05-27 15:53:20 +0000
commit450f684474a6c7bb4221ac973bc850b59891719d (patch)
tree4289b8dcb60fc96d9c324ff85a7f606862f63b42
parent25feb4b4a4615bf26e5ecc321310efb104bb8b11 (diff)
parent1849ac2b27542c3ab4e0ae76f68f467bac788d81 (diff)
downloadgitlab-ce-450f684474a6c7bb4221ac973bc850b59891719d.tar.gz
Merge branch 'if-doc-ee_specific_api-params' into 'master'
Update development doc on EE specific API params See merge request gitlab-org/gitlab-ce!28608
-rw-r--r--doc/development/ee_features.md53
1 files changed, 33 insertions, 20 deletions
diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md
index 485d69fc997..857595330aa 100644
--- a/doc/development/ee_features.md
+++ b/doc/development/ee_features.md
@@ -557,40 +557,56 @@ 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
interface first here.
-For example, suppose we have a few more optional params for EE, given this CE
-API code:
+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
+before it would be used in the class.
```ruby
module API
- class MergeRequests < Grape::API
- # EE::API::MergeRequests would override the following helpers
- helpers do
- params :optional_params_ee do
+ class Projects < Grape::API
+ helpers Helpers::ProjectsHelpers
+ end
+end
+```
+
+Given this CE API `params`:
+
+```ruby
+module API
+ module Helpers
+ module ProjectsHelpers
+ extend ActiveSupport::Concern
+ extend Grape::API::Helpers
+
+ params :optional_project_params_ce do
+ # CE specific params go here...
end
- end
- params :optional_params do
- # CE specific params go here...
+ params :optional_project_params_ee do
+ end
- use :optional_params_ee
+ params :optional_project_params do
+ use :optional_project_params_ce
+ use :optional_project_params_ee
+ end
end
end
end
-API::MergeRequests.prepend(EE::API::MergeRequests)
+API::Helpers::ProjectsHelpers.prepend(EE::API::Helpers::ProjectsHelpers)
```
-And then we could override it in EE module:
+We could override it in EE module:
```ruby
module EE
module API
- module MergeRequests
- extend ActiveSupport::Concern
+ module Helpers
+ module ProjectsHelpers
+ extend ActiveSupport::Concern
- prepended do
- helpers do
- params :optional_params_ee do
+ prepended do
+ params :optional_project_params_ee do
# EE specific params go here...
end
end
@@ -600,9 +616,6 @@ module EE
end
```
-This way, the only difference between CE and EE for that API file would be
-`prepend EE::API::MergeRequests`.
-
#### EE helpers
To make it easy for an EE module to override the CE helpers, we need to define