Class: HasSetting::Formatters::NilSafeFormatter
- Inherits:
-
Object
- Object
- HasSetting::Formatters::NilSafeFormatter
- Defined in:
- lib/has_setting/formatters.rb
Overview
Helper class which handles nil values
Direct Known Subclasses
BooleanFormatter, BooleansFormatter, FloatFormatter, FloatsFormatter, IntFormatter, IntsFormatter, StrictBooleanFormatter, StrictBooleansFormatter, StringFormatter, StringsFormatter
Instance Method Summary collapse
-
#to_s(value) ⇒ Object
Converts the value to String for storing in DB Nil is returned for nil values.
-
#to_type(value) ⇒ Object
Converts the String from DB to the specified type Nil is returned for nil values.
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 |