Method: DBI::TypeUtil.convert
- Defined in:
- lib/dbi/typeutil.rb
.convert(driver_name, obj) ⇒ Object
Convert object for driver_name. See #register_conversion for a complete explanation of how type conversion is performed.
If the conversion is instructed to cascade, it will go to the special “default” conversion, which is a pre-defined common case (and mutable) ruleset for native types. Note that it will use the result from the first conversion, not what was originally passed. Be sure to leave the object untouched if that is your intent. E.g., if your DBD converts an Integer to String and tells it to cascade, the “default” conversion will get a String and quote it, not an Integer (which has different rules).
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dbi/typeutil.rb', line 48 def self.convert(driver_name, obj) if @@conversions[driver_name] newobj, cascade = @@conversions[driver_name].call(obj) if cascade return @@conversions["default"].call(newobj) end return newobj end return @@conversions["default"].call(obj) end |