Commit d63d6e82 authored by Peter Leitzen's avatar Peter Leitzen

Prefer cattr_accessor over ivar in marginalia

Note, the access to this variable remains thread-unsafe.

This silences the following warning:
    warning: instance variable @enabled not initialized
parent 4c541c6a
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Gitlab module Gitlab
module Marginalia module Marginalia
cattr_accessor :enabled, default: false
MARGINALIA_FEATURE_FLAG = :marginalia MARGINALIA_FEATURE_FLAG = :marginalia
def self.set_application_name def self.set_application_name
...@@ -15,14 +17,14 @@ module Gitlab ...@@ -15,14 +17,14 @@ module Gitlab
end end
def self.cached_feature_enabled? def self.cached_feature_enabled?
!!@enabled enabled
end end
def self.set_feature_cache def self.set_feature_cache
# During db:create and db:bootstrap skip feature query as DB is not available yet. # During db:create and db:bootstrap skip feature query as DB is not available yet.
return false unless ActiveRecord::Base.connected? && Gitlab::Database.cached_table_exists?('features') return false unless ActiveRecord::Base.connected? && Gitlab::Database.cached_table_exists?('features')
@enabled = Feature.enabled?(MARGINALIA_FEATURE_FLAG) self.enabled = Feature.enabled?(MARGINALIA_FEATURE_FLAG)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment