Module: SettingsManager::Validation::ClassMethods
- Defined in:
- lib/settings-manager/validation.rb
Instance Method Summary collapse
- #allowed_settings_keys(keys = nil) ⇒ Object
- #key_allowed?(key) ⇒ Boolean
- #validates_setting(value, options = {}) ⇒ Object
Instance Method Details
#allowed_settings_keys(keys = nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/settings-manager/validation.rb', line 20 def allowed_settings_keys(keys = nil) if keys.present? && keys.kind_of?(Array) @allowed_settings_keys = keys else @allowed_settings_keys || [] end end |
#key_allowed?(key) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/settings-manager/validation.rb', line 28 def key_allowed?(key) if allowed_settings_keys.any? allowed_settings_keys.include?(key.to_sym) else true end end |
#validates_setting(value, options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/settings-manager/validation.rb', line 36 def validates_setting(value, = {}) [:if] = Proc.new { |record| value.to_s == record.key.to_s } validates(:value, ) end |