class PG::BasicTypeRegistry

This class defines the mapping between PostgreSQL types and encoder/decoder classes for PG::BasicTypeMapForResults, PG::BasicTypeMapForQueries and PG::BasicTypeMapBasedOnResult.

Additional types can be added like so:

require 'pg'
require 'ipaddr'

class InetDecoder < PG::SimpleDecoder
  def decode(string, tuple=nil, field=nil)
    IPAddr.new(string)
  end
end
class InetEncoder < PG::SimpleEncoder
  def encode(ip_addr)
    ip_addr.to_s
  end
end

conn = PG.connect
regi = PG::BasicTypeRegistry.new.register_default_types
regi.register_type(0, 'inet', InetEncoder, InetDecoder)
conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn, registry: regi)