Class: PG::RecordCoder

Inherits:
Coder
  • Object
show all
Defined in:
ext/pg_record_coder.c,
lib/pg/coder.rb,
ext/pg_record_coder.c

Overview

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

Direct Known Subclasses

RecordDecoder, RecordEncoder

Constant Summary

Constants inherited from Coder

Coder::FORMAT_ERROR_MASK, Coder::FORMAT_ERROR_TO_PARTIAL, Coder::FORMAT_ERROR_TO_RAISE, Coder::FORMAT_ERROR_TO_STRING, Coder::TIMESTAMP_APP_LOCAL, Coder::TIMESTAMP_APP_UTC, Coder::TIMESTAMP_DB_LOCAL, Coder::TIMESTAMP_DB_UTC

Instance Attribute Summary

Attributes inherited from Coder

#name

Instance Method Summary collapse

Methods inherited from Coder

#==, #dup, #flags, #flags=, #format, #format=, #initialize, #inspect, #inspect_short, #marshal_dump, #marshal_load, #oid, #oid=

Constructor Details

This class inherits a constructor from PG::Coder

Instance Method Details

#to_hObject



98
99
100
101
102
# File 'lib/pg/coder.rb', line 98

def to_h
	super.merge!({
		type_map: type_map,
	})
end

#type_mapPG::TypeMap

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

Returns:



75
76
77
78
79
80
81
# File 'ext/pg_record_coder.c', line 75

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

	return this->typemap;
}

#type_map=(map) ⇒ Object

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.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'ext/pg_record_coder.c', line 55

static VALUE
pg_recordcoder_type_map_set(VALUE self, VALUE type_map)
{
	t_pg_recordcoder *this = DATA_PTR( 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 ) );
	}
	this->typemap = type_map;

	return type_map;
}