Class: PG::RecordCoder
- 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
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
Instance Method Summary collapse
- #to_h ⇒ Object
-
#type_map ⇒ PG::TypeMap
The PG::TypeMap that will be used for encoding and decoding of columns.
-
#type_map=(map) ⇒ Object
Defines how single columns are encoded or decoded.
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_h ⇒ Object
100 101 102 103 104 |
# File 'lib/pg/coder.rb', line 100 def to_h { **super, type_map: type_map, } end |
#type_map ⇒ PG::TypeMap
The PG::TypeMap that will be used for encoding and decoding of columns.
105 106 107 108 109 110 111 |
# File 'ext/pg_record_coder.c', line 105
static VALUE
pg_recordcoder_type_map_get(VALUE self)
{
t_pg_recordcoder *this = RTYPEDDATA_DATA( 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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'ext/pg_record_coder.c', line 84
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;
}
|