Class: Amalgalite::TypeMaps::StorageMap

Inherits:
Amalgalite::TypeMap show all
Defined in:
lib/amalgalite/type_maps/storage_map.rb

Overview

An Amalagliate TypeMap that has a one-to-one conversion between SQLite types and Ruby classes

Instance Method Summary collapse

Instance Method Details

#bind_type_of(obj) ⇒ Object

A straight logical mapping (for me at least) of basic Ruby classes to SQLite types, if nothing can be found then default to TEXT.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/amalgalite/type_maps/storage_map.rb', line 16

def bind_type_of( obj )
  case obj
  when Float
    ::Amalgalite::SQLite3::Constants::DataType::FLOAT
  when Integer
    ::Amalgalite::SQLite3::Constants::DataType::INTEGER
  when NilClass
    ::Amalgalite::SQLite3::Constants::DataType::NULL
  when ::Amalgalite::Blob
    ::Amalgalite::SQLite3::Constants::DataType::BLOB
  else
    ::Amalgalite::SQLite3::Constants::DataType::TEXT
  end
end

#result_value_of(delcared_type, value) ⇒ Object

Do no mapping, just return the value as it was retrieved from SQLite.



34
35
36
# File 'lib/amalgalite/type_maps/storage_map.rb', line 34

def result_value_of( delcared_type, value )
  return value
end