summaryrefslogtreecommitdiff
path: root/doc/development/utilities.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/utilities.md')
-rw-r--r--doc/development/utilities.md30
1 files changed, 15 insertions, 15 deletions
diff --git a/doc/development/utilities.md b/doc/development/utilities.md
index d7baa6b23a5..b9b4c6448e2 100644
--- a/doc/development/utilities.md
+++ b/doc/development/utilities.md
@@ -10,11 +10,11 @@ We have developed a number of utilities to help ease development:
## `MergeHash`
-Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/utils/merge_hash.rb):
+Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils/merge_hash.rb):
- Deep merges an array of hashes:
- ``` ruby
+ ```ruby
Gitlab::Utils::MergeHash.merge(
[{ hello: ["world"] },
{ hello: "Everyone" },
@@ -25,7 +25,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
Gives:
- ``` ruby
+ ```ruby
[
{
hello:
@@ -41,7 +41,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
- Extracts all keys and values from a hash into an array:
- ``` ruby
+ ```ruby
Gitlab::Utils::MergeHash.crush(
{ hello: "world", this: { crushes: ["an entire", "hash"] } }
)
@@ -49,13 +49,13 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
Gives:
- ``` ruby
+ ```ruby
[:hello, "world", :this, :crushes, "an entire", "hash"]
```
## `Override`
-Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/utils/override.rb):
+Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils/override.rb):
- This utility can help you check if one method would override
another or not. It is the same concept as Java's `@Override` annotation
@@ -69,7 +69,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi
Here's a simple example:
- ``` ruby
+ ```ruby
class Base
def execute
end
@@ -86,7 +86,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi
This also works on modules:
- ``` ruby
+ ```ruby
module Extension
extend ::Gitlab::Utils::Override
@@ -152,7 +152,7 @@ Derived.f # => nil
## `StrongMemoize`
-Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/utils/strong_memoize.rb):
+Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils/strong_memoize.rb):
- Memoize the value even if it is `nil` or `false`.
@@ -164,7 +164,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
Instead of writing patterns like this:
- ``` ruby
+ ```ruby
class Find
def result
return @result if defined?(@result)
@@ -176,7 +176,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
You could write it like:
- ``` ruby
+ ```ruby
class Find
include Gitlab::Utils::StrongMemoize
@@ -190,7 +190,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
- Clear memoization
- ``` ruby
+ ```ruby
class Find
include Gitlab::Utils::StrongMemoize
end
@@ -200,7 +200,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
## `RequestCache`
-Refer to [`request_cache.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/cache/request_cache.rb).
+Refer to [`request_cache.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/cache/request_cache.rb).
This module provides a simple way to cache values in RequestStore,
and the cache key would be based on the class name, method name,
@@ -209,7 +209,7 @@ method level values, and optional method arguments.
A simple example that only uses the instance level customised values is:
-``` ruby
+```ruby
class UserAccess
extend Gitlab::Cache::RequestCache
@@ -230,7 +230,7 @@ instance variable so the cache logic would be the same.
We can also set different strategies for different methods:
-``` ruby
+```ruby
class Commit
extend Gitlab::Cache::RequestCache