Class: EasySettings::BooleanKey

Inherits:
Key show all
Defined in:
lib/redmine_extensions/easy_settings/key.rb

Instance Attribute Summary

Attributes inherited from Key

#name, #options

Instance Method Summary collapse

Methods inherited from Key

#after_save, #default, #disabled_from_params?, init, #initialize, #skip_blank_params?

Constructor Details

This class inherits a constructor from EasySettings::Key

Instance Method Details

#from_params(easy_setting, value) ⇒ Object



68
69
70
# File 'lib/redmine_extensions/easy_settings/key.rb', line 68

def from_params(easy_setting, value)
  value.to_s.to_boolean
end

#validate(easy_setting) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/redmine_extensions/easy_settings/key.rb', line 72

def validate(easy_setting)
  easy_setting.instance_eval do
    if ![nil, true, false].include?(value)
      errors.add(:base, "#{name} must be boolean")
    end
  end
end