Class: Gitlab::Database::QueryAnalyzers::Base
- Inherits:
-
Object
- Object
- Gitlab::Database::QueryAnalyzers::Base
show all
- Defined in:
- lib/gitlab/database/query_analyzers/base.rb
Constant Summary
collapse
- QueryAnalyzerError =
‘Exception` to ensure that is not easily rescued when running in test env
Class.new(Exception)
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.suppress_in_rspec=(value) ⇒ Object
Sets the attribute suppress_in_rspec
33
34
35
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 33
def suppress_in_rspec=(value)
@suppress_in_rspec = value
end
|
Class Method Details
.analyze(parsed) ⇒ Object
60
61
62
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 60
def self.analyze(parsed)
raise NotImplementedError
end
|
.analyzer_key ⇒ Object
72
73
74
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 72
def self.analyzer_key
@analyzer_key ||= self.name.demodulize.underscore.to_sym
end
|
.begin! ⇒ Object
44
45
46
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 44
def self.begin!
Thread.current[self.context_key] = {}
end
|
.context ⇒ Object
52
53
54
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 52
def self.context
Thread.current[self.context_key]
end
|
.context_key ⇒ Object
64
65
66
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 64
def self.context_key
@context_key ||= "analyzer_#{self.analyzer_key}_context".to_sym
end
|
.enabled? ⇒ Boolean
56
57
58
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 56
def self.enabled?
raise NotImplementedError
end
|
.end! ⇒ Object
48
49
50
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 48
def self.end!
Thread.current[self.context_key] = nil
end
|
.requires_tracking?(parsed) ⇒ Boolean
14
15
16
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 14
def self.requires_tracking?(parsed)
false
end
|
.suppress=(value) ⇒ Object
18
19
20
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 18
def self.suppress=(value)
Thread.current[self.suppress_key] = value
end
|
.suppress_key ⇒ Object
68
69
70
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 68
def self.suppress_key
@suppress_key ||= "analyzer_#{self.analyzer_key}_suppressed".to_sym
end
|
.suppressed? ⇒ Boolean
10
11
12
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 10
def self.suppressed?
Thread.current[self.suppress_key] || @suppress_in_rspec
end
|
.with_suppressed(value = true, &blk) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 36
def self.with_suppressed(value = true, &blk)
previous = self.suppressed?
self.suppress = value
yield
ensure
self.suppress = previous
end
|