Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/utilities.md')
-rw-r--r--doc/development/utilities.md18
1 files changed, 17 insertions, 1 deletions
diff --git a/doc/development/utilities.md b/doc/development/utilities.md
index 45a6b74f33a..551834670b3 100644
--- a/doc/development/utilities.md
+++ b/doc/development/utilities.md
@@ -199,10 +199,26 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/maste
end
strong_memoize_attr :result
- strong_memoize_attr :enabled?, :enabled
def enabled?
Feature.enabled?(:some_feature)
end
+ strong_memoize_attr :enabled?, :enabled
+ end
+ ```
+
+ There's also `strong_memoize_with` to help memoize methods that take arguments.
+ This should be used for methods that have a low number of possible values
+ as arguments or with consistent repeating arguments in a loop.
+
+ ```ruby
+ class Find
+ include Gitlab::Utils::StrongMemoize
+
+ def result(basic: true)
+ strong_memoize_with(:result, basic) do
+ search(basic)
+ end
+ end
end
```