Class: HasSetting::Formatters::NilSafeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/has_setting/formatters.rb

Overview

Helper class which handles nil values

Instance Method Summary collapse

Instance Method Details

#to_s(value) ⇒ Object

Converts the value to String for storing in DB Nil is returned for nil values



32
33
34
# File 'lib/has_setting/formatters.rb', line 32

def to_s(value)
  safe_to_s(value) unless value == nil
end

#to_type(value) ⇒ Object

Converts the String from DB to the specified type Nil is returned for nil values



27
28
29
# File 'lib/has_setting/formatters.rb', line 27

def to_type(value)
  safe_to_type(value) unless value == nil
end