Remove class_eval in favor of define_method
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
From https://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html:
TL;DR: depending on your app, using define_method is faster on boot, consumes less memory, and probably doesn’t significantly impact performance.
We use this in a few places:
$ git grep class_eval
app/models/service.rb: class_eval %{
app/models/service.rb: class_eval %{
lib/gitlab/ci/config/entry/validatable.rb: @validations.each { |rules| validator.class_eval(&rules) }
lib/gitlab/metrics/instrumentation.rb: proxy_module.class_eval <<-EOF, __FILE__, __LINE__ + 1
lib/gitlab/patch/prependable.rb: base.class_eval(&@_prepended_block)
lib/tasks/gitlab/uploads/migrate.rake: Upload.class_eval { include EachBatch } unless Upload < EachBatch
Edited by 🤖 GitLab Bot 🤖