Class: EasySettings::IntegerKey

Inherits:
Key
  • Object
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



84
85
86
# File 'lib/redmine_extensions/easy_settings/key.rb', line 84

def from_params(easy_setting, value)
  value.try(:to_i)
end

#validate(easy_setting) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/redmine_extensions/easy_settings/key.rb', line 88

def validate(easy_setting)
  easy_setting.instance_eval do
    if !value.nil? && !value.is_a?(Integer)
      errors.add(:base, "#{name} must be inetger")
    end
  end
end