Module: Cassandra::Mapper::Convert

Extended by:
Convert
Included in:
Convert
Defined in:
lib/cassandra/mapper/convert.rb

Constant Summary collapse

TEXT_TYPE =
'UTF8Type'
TYPES =
{
  uuid:     'TimeUUIDType',
  integer:  'Int32Type',
  time:     'DateType'
}

Instance Method Summary collapse

Instance Method Details

#from(type, value) ⇒ Object



19
20
21
# File 'lib/cassandra/mapper/convert.rb', line 19

def from(type, value)
  send "from_#{type}", value
end

#round(type, value) ⇒ Object



23
24
25
# File 'lib/cassandra/mapper/convert.rb', line 23

def round(type, value)
  from type, to(type, value)
end

#to(type, value) ⇒ Object



15
16
17
# File 'lib/cassandra/mapper/convert.rb', line 15

def to(type, value)
  send "to_#{type}", value
end

#type(symbol) ⇒ Object



11
12
13
# File 'lib/cassandra/mapper/convert.rb', line 11

def type(symbol)
  TYPES.fetch symbol, TEXT_TYPE
end