Class: PoolLint::AllowedSettings
- Inherits:
-
Object
- Object
- PoolLint::AllowedSettings
- Defined in:
- lib/poollint/allowed_settings.rb
Constant Summary collapse
- UNCONFIGURED =
Object.new.freeze
Instance Method Summary collapse
- #allow?(name, value) ⇒ Boolean
-
#initialize(rules) ⇒ AllowedSettings
constructor
A new instance of AllowedSettings.
Constructor Details
#initialize(rules) ⇒ AllowedSettings
Returns a new instance of AllowedSettings.
7 8 9 |
# File 'lib/poollint/allowed_settings.rb', line 7 def initialize(rules) @rules = normalize(rules) end |
Instance Method Details
#allow?(name, value) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/poollint/allowed_settings.rb', line 11 def allow?(name, value) rule = @rules.fetch(name) { @rules.fetch(name.to_sym, UNCONFIGURED) } case rule when UNCONFIGURED then false when nil, true then true when Proc then rule.call(value) when Regexp then rule.match?(value.to_s) when Array then rule.include?(value) else rule == value end end |