Class: RuleRegistry
- Inherits:
-
Object
- Object
- RuleRegistry
- Defined in:
- lib/cfn-nag/rule_registry.rb
Instance Attribute Summary collapse
-
#duplicate_ids ⇒ Object
readonly
Returns the value of attribute duplicate_ids.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #by_id(id) ⇒ Object
- #definition(id:, type:, message:) ⇒ Object
- #duplicate_ids? ⇒ Boolean
- #failings ⇒ Object
-
#initialize ⇒ RuleRegistry
constructor
A new instance of RuleRegistry.
- #warnings ⇒ Object
Constructor Details
#initialize ⇒ RuleRegistry
Returns a new instance of RuleRegistry.
8 9 10 11 |
# File 'lib/cfn-nag/rule_registry.rb', line 8 def initialize @rules = [] @duplicate_ids = [] end |
Instance Attribute Details
#duplicate_ids ⇒ Object (readonly)
Returns the value of attribute duplicate_ids.
6 7 8 |
# File 'lib/cfn-nag/rule_registry.rb', line 6 def duplicate_ids @duplicate_ids end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
6 7 8 |
# File 'lib/cfn-nag/rule_registry.rb', line 6 def rules @rules end |
Instance Method Details
#by_id(id) ⇒ Object
36 37 38 |
# File 'lib/cfn-nag/rule_registry.rb', line 36 def by_id(id) @rules.find { |rule| rule.id == id } end |
#definition(id:, type:, message:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cfn-nag/rule_registry.rb', line 17 def definition(id:, type:, message:) rule_definition = RuleDefinition.new(id: id, type: type, message: ) existing_def = by_id id if existing_def.nil? add_rule rule_definition else @duplicate_ids << { id: id, new_message: , registered_message: existing_def. } end end |
#duplicate_ids? ⇒ Boolean
13 14 15 |
# File 'lib/cfn-nag/rule_registry.rb', line 13 def duplicate_ids? @duplicate_ids.count.positive? end |
#failings ⇒ Object
44 45 46 |
# File 'lib/cfn-nag/rule_registry.rb', line 44 def failings @rules.select { |rule| rule.type == RuleDefinition::FAILING_VIOLATION } end |
#warnings ⇒ Object
40 41 42 |
# File 'lib/cfn-nag/rule_registry.rb', line 40 def warnings @rules.select { |rule| rule.type == RuleDefinition::WARNING } end |