Module: RDBI::Type::Out

Defined in:
lib/rdbi/types.rb

Overview

The default output type map. As explained in RDBI::Type, these are keyed by symbol and are loosely related to the type, and are compared against the proper RDBI::Column object to figure out which filter to call.

Constant Summary collapse

DEFAULTS =
{
  :integer     => RDBI::Type.filterlist(Filters::STR_TO_INT),
  :decimal     => RDBI::Type.filterlist(Filters::STR_TO_DEC),
  :datetime    => RDBI::Type.filterlist(TypeLib::Canned.build_strptime_filter(DEFAULT_STRFTIME_FILTER)),
  :timestamp   => RDBI::Type.filterlist(TypeLib::Canned.build_strptime_filter(DEFAULT_STRFTIME_FILTER)),
  :boolean     => RDBI::Type.filterlist(Filters::TO_BOOLEAN),
  :default     => RDBI::Type.filterlist()
}

Class Method Summary collapse

Class Method Details

.convert(obj, column, type_hash) ⇒ Object

Perform a conversion. Accepts the object to convert, a RDBI::Column object, and a type map (a Hash).


155
156
157
158
159
160
161
162
163
# File 'lib/rdbi/types.rb', line 155

def self.convert(obj, column, type_hash)
  fl = type_hash[column.ruby_type]

  unless fl
    fl = type_hash[:default]
  end

  fl.execute(obj)
end