Class: Rapid::Setting::IntegerSetting

Inherits:
Base
  • Object
show all
Defined in:
lib/rapid/setting/integer_setting.rb

Instance Attribute Summary

Attributes inherited from Base

#default_value, #full_name, #name, #namespace

Instance Method Summary collapse

Methods inherited from Base

#define_helpers, #initialize

Constructor Details

This class inherits a constructor from Rapid::Setting::Base

Instance Method Details

#load(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rapid/setting/integer_setting.rb', line 6

def load value
  if value == nil || value == "" || value == false
    nil
    
  elsif value.is_a?(Integer)
    value
    
  elsif value.is_a?(String) && value =~ /[0-9]+/
    value.to_i
    
  else
    raise InvalidSettingError.new(self, value)
  end
end