Class: QueryGuard::Analyzers::Registry
- Inherits:
-
Object
- Object
- QueryGuard::Analyzers::Registry
- Defined in:
- lib/query_guard/analyzers/registry.rb
Overview
Registry for managing analyzer instances. Provides global registration and per-request analysis coordination.
Instance Method Summary collapse
-
#all ⇒ Hash{Symbol => Base}
Get all registered analyzers.
-
#analyze(context, config) ⇒ Array<Core::Finding>
Run all enabled analyzers against the context.
-
#clear ⇒ Object
Clear all registered analyzers.
-
#get(name) ⇒ Base?
Retrieve analyzer by name.
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#register(name, analyzer) ⇒ Object
Register an analyzer instance.
-
#registered?(name) ⇒ Boolean
Check if analyzer is registered.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
8 9 10 |
# File 'lib/query_guard/analyzers/registry.rb', line 8 def initialize @analyzers = {} end |
Instance Method Details
#all ⇒ Hash{Symbol => Base}
Get all registered analyzers
34 35 36 |
# File 'lib/query_guard/analyzers/registry.rb', line 34 def all @analyzers.dup end |
#analyze(context, config) ⇒ Array<Core::Finding>
Run all enabled analyzers against the context
42 43 44 45 46 47 48 49 |
# File 'lib/query_guard/analyzers/registry.rb', line 42 def analyze(context, config) findings = [] @analyzers.each do |name, analyzer| next unless analyzer.enabled?(config) findings.concat(analyzer.analyze(context, config)) end findings end |
#clear ⇒ Object
Clear all registered analyzers
52 53 54 |
# File 'lib/query_guard/analyzers/registry.rb', line 52 def clear @analyzers.clear end |
#get(name) ⇒ Base?
Retrieve analyzer by name
23 24 25 |
# File 'lib/query_guard/analyzers/registry.rb', line 23 def get(name) @analyzers[name.to_sym] end |
#register(name, analyzer) ⇒ Object
Register an analyzer instance
15 16 17 18 |
# File 'lib/query_guard/analyzers/registry.rb', line 15 def register(name, analyzer) raise ArgumentError, "Analyzer must inherit from Base" unless analyzer.is_a?(Base) @analyzers[name.to_sym] = analyzer end |
#registered?(name) ⇒ Boolean
Check if analyzer is registered
28 29 30 |
# File 'lib/query_guard/analyzers/registry.rb', line 28 def registered?(name) @analyzers.key?(name.to_sym) end |