Class: StoreSchema::Converter::Integer
- Defined in:
- lib/store_schema/converter/integer.rb
Constant Summary collapse
- INT_FORMAT =
Returns the int value format.
/^\d+$/
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#from_db ⇒ Integer
Converts the Base#value to a Ruby-type value.
-
#to_db ⇒ String, false
Converts the Base#value to a database-storable value.
Methods inherited from Base
Constructor Details
This class inherits a constructor from StoreSchema::Converter::Base
Instance Method Details
#from_db ⇒ Integer
Converts the Base#value to a Ruby-type value.
34 35 36 |
# File 'lib/store_schema/converter/integer.rb', line 34 def from_db value.to_i end |
#to_db ⇒ String, false
Converts the Base#value to a database-storable value.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/store_schema/converter/integer.rb', line 15 def to_db case value when ::Integer value.to_s when ::String if value.match(INT_FORMAT) value else false end else false end end |