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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
fd54d7a2
Commit
fd54d7a2
authored
Jan 12, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more docs to doc/development/utilities.md
parent
cfd75101
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
doc/development/ee_features.md
doc/development/ee_features.md
+4
-1
doc/development/utilities.md
doc/development/utilities.md
+45
-0
No files found.
doc/development/ee_features.md
View file @
fd54d7a2
...
...
@@ -87,7 +87,7 @@ still having access the class's implementation with `super`.
There are a few gotchas with it:
-
you should always
`extend ::Gitlab::Utils::Override`
and use
`override`
to
-
you should always
[
`extend ::Gitlab::Utils::Override`
]
and use
`override`
to
guard the "overrider" method to ensure that if the method gets renamed in
CE, the EE override won't be silently forgotten.
-
when the "overrider" would add a line in the middle of the CE
...
...
@@ -192,6 +192,8 @@ module EE
end
```
[
`extend ::Gitlab::Utils::Override`
]:
utilities.md#override
#### Use self-descriptive wrapper methods
When it's not possible/logical to modify the implementation of a
...
...
@@ -212,6 +214,7 @@ end
In EE, the implementation
`ee/app/models/ee/users.rb`
would be:
```
ruby
override
:full_private_access?
def
full_private_access?
super
||
auditor?
end
...
...
doc/development/utilities.md
View file @
fd54d7a2
...
...
@@ -45,6 +45,51 @@ We developed a number of utilities to ease development.
[:hello, "world", :this, :crushes, "an entire", "hash"]
```
## [`Override`](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/utils/override.rb)
*
This utility could help us check if a particular method would override
another method or not. It has the same idea of Java's
`@Override`
annotation
or Scala's
`override`
keyword. However we only do this check when
`ENV['STATIC_VERIFICATION']`
is set to avoid production runtime overhead.
This is useful to check:
* If we have typos in overriding methods.
* If we renamed the overridden methods, making original overriding methods
overrides nothing.
Here's a simple example:
``` ruby
class Base
def execute
end
end
class Derived < Base
extend ::Gitlab::Utils::Override
override :execute # Override check happens here
def execute
end
end
```
This also works on modules:
``` ruby
module Extension
extend ::Gitlab::Utils::Override
override :execute # Modules do not check this immediately
def execute
end
end
class Derived < Base
prepend Extension # Override check happens here, not in the module
end
```
## [`StrongMemoize`](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/utils/strong_memoize.rb)
*
Memoize the value even if it is
`nil`
or
`false`
.
...
...
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