class StoreSchema::Converter::Integer

Constants

INT_FORMAT

@return [Regexp] the int value format.

Public Instance Methods

from_db() click to toggle source

Converts the {#value} to a Ruby-type value.

@return [Integer]

# File lib/store_schema/converter/integer.rb, line 34
def from_db
  value.to_i
end
to_db() click to toggle source

Converts the {#value} to a database-storable value.

@return [String, false] false if {#value} is an invalid date-type.

# 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