# class PG::RecordCoder

This is the base class for all type cast classes for COPY data,

### Public Instance Methods

to_h() click to toggle source
Calls superclass method `PG::Coder#to_h`

    # File lib/pg/coder.rb, line 101
    def to_h
            { **super,
                    type_map: type_map,
            }
    end

type_map → PG::TypeMap click to toggle source

The `PG::TypeMap` that will be used for encoding and decoding of columns.

    static VALUE
    pg_recordcoder_type_map_get(VALUE self)
    {
            t_pg_recordcoder *this = RTYPEDDATA_DATA( self );

            return this->typemap;
    }

type_map = map click to toggle source

Defines how single columns are encoded or decoded. `map` must be a kind of `PG::TypeMap` .

Defaults to a `PG::TypeMapAllStrings` , so that `PG::TextEncoder::String` respectively `PG::TextDecoder::String` is used for encoding/decoding of each column.

    static VALUE
    pg_recordcoder_type_map_set(VALUE self, VALUE type_map)
    {
            t_pg_recordcoder *this = RTYPEDDATA_DATA( self );

            rb_check_frozen(self);
            if ( !rb_obj_is_kind_of(type_map, rb_cTypeMap) ){
                    rb_raise( rb_eTypeError, "wrong elements type %s (expected some kind of PG::TypeMap)",
                                    rb_obj_classname( type_map ) );
            }
            RB_OBJ_WRITE(self, &this->typemap, type_map);

            return type_map;
    }