Class: QueryGuard::Analyzers::Base
- Inherits:
-
Object
- Object
- QueryGuard::Analyzers::Base
- Defined in:
- lib/query_guard/analyzers/base.rb
Overview
Base class for all rule-based analyzers.
Subclasses implement analyze(context, config) to produce findings.
Direct Known Subclasses
QueryCountAnalyzer, QueryRiskAnalyzer, SelectStarAnalyzer, SlowQueryAnalyzer, Migrations::MigrationAnalyzer
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#analyze(context, config) ⇒ Array<Core::Finding>
Analyze the context and produce findings.
-
#enabled?(config) ⇒ Boolean
Enabled check - allows per-analyzer enable/disable.
-
#initialize(name) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(name) ⇒ Base
Returns a new instance of Base.
10 11 12 |
# File 'lib/query_guard/analyzers/base.rb', line 10 def initialize(name) @name = name.to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/query_guard/analyzers/base.rb', line 8 def name @name end |
Instance Method Details
#analyze(context, config) ⇒ Array<Core::Finding>
Analyze the context and produce findings. Must return an array of Finding objects.
20 21 22 |
# File 'lib/query_guard/analyzers/base.rb', line 20 def analyze(context, config) raise NotImplementedError, "#{self.class} must implement #analyze" end |
#enabled?(config) ⇒ Boolean
Enabled check - allows per-analyzer enable/disable
25 26 27 |
# File 'lib/query_guard/analyzers/base.rb', line 25 def enabled?(config) !config.disabled_analyzers&.include?(name) end |