class StoreSchema::Converter

Constants

MAPPING

@return [Hash] a mapping between the configuration block

and the converter classes.

Attributes

type[R]

@return [Symbol]

value[R]

@return [Object]

Public Class Methods

new(value, type) click to toggle source

@param value [Object] any kind of value that should be stored @param type [Symbol] the type of the value

# File lib/store_schema/converter.rb, line 32
def initialize(value, type)
  @value = value
  @type  = type
end

Public Instance Methods

from_db() click to toggle source

Converts {#value} from a database-storable value to a Ruby-type value.

@return [Object]

# File lib/store_schema/converter.rb, line 49
def from_db
  MAPPING[type].new(value).from_db
end
to_db() click to toggle source

Converts {#value} from a Ruby-type value to a database-storable value.

@return [String]

# File lib/store_schema/converter.rb, line 41
def to_db
  MAPPING[type].new(value).to_db
end