Class: PgCanary::RuleConfig
- Inherits:
-
Object
- Object
- PgCanary::RuleConfig
- Defined in:
- lib/pg_canary/configuration.rb
Overview
Per-rule settings. enabled / severity default to nil, meaning
"use the rule class's default". Accessors for rule-specific options
(e.g. config.rules.deep_offset.threshold = 2000) are generated from the
rule class's declared options, so a typo raises NoMethodError instead of
silently creating a setting nobody reads.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#severity ⇒ Object
Returns the value of attribute severity.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(option_defaults = {}) ⇒ RuleConfig
constructor
A new instance of RuleConfig.
Constructor Details
#initialize(option_defaults = {}) ⇒ RuleConfig
Returns a new instance of RuleConfig.
55 56 57 58 59 60 61 |
# File 'lib/pg_canary/configuration.rb', line 55 def initialize(option_defaults = {}) @options = option_defaults.dup @options.each_key do |name| define_singleton_method(name) { @options[name] } define_singleton_method(:"#{name}=") { |value| @options[name] = value } end end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
53 54 55 |
# File 'lib/pg_canary/configuration.rb', line 53 def enabled @enabled end |
#severity ⇒ Object
Returns the value of attribute severity.
53 54 55 |
# File 'lib/pg_canary/configuration.rb', line 53 def severity @severity end |
Instance Method Details
#[](key) ⇒ Object
63 64 65 |
# File 'lib/pg_canary/configuration.rb', line 63 def [](key) @options.fetch(key.to_sym) end |