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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-29 21:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-29 21:09:17 +0300
commit2516f0d87bf4504cf0d626a0584b2eebe459749b (patch)
tree52d1188485f7362da9d87b526e14e49be00fa9a1 /doc/development/utilities.md
parent10052df7536415c192788799b294c9a5ecf07ce7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/utilities.md')
-rw-r--r--doc/development/utilities.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/doc/development/utilities.md b/doc/development/utilities.md
index dc76f26831f..f0f71842d69 100644
--- a/doc/development/utilities.md
+++ b/doc/development/utilities.md
@@ -109,6 +109,48 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi
Because only a class or prepended module can actually override a method.
Including or extending a module into another cannot override anything.
+### Interactions with `ActiveSupport::Concern`, `prepend`, and `class_methods`
+
+When you use `ActiveSupport::Concern` that includes class methods, you do not
+get expected results because `ActiveSupport::Concern` doesn't work like a
+regular Ruby module.
+
+Since we already have `Prependable` as a patch for `ActiveSupport::Concern`
+to enable `prepend`, it has consequences with how it would interact with
+`override` and `class_methods`. We add a workaround directly into
+`Prependable` to resolve the problem, by `extend`ing `ClassMethods` into the
+defining module.
+
+This allows us to use `override` to verify `class_methods` used in the
+context mentioned above. This workaround only applies when we run the
+verification, not when running the application itself.
+
+Here are example code blocks that demonstrate the effect of this workaround:
+following codes:
+
+```ruby
+module Base
+ extend ActiveSupport::Concern
+
+ class_methods do
+ def f
+ end
+ end
+end
+
+module Derived
+ include Base
+end
+
+# Without the workaround
+Base.f # => NoMethodError
+Derived.f # => nil
+
+# With the workaround
+Base.f # => nil
+Derived.f # => nil
+```
+
## `StrongMemoize`
Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/utils/strong_memoize.rb):