class PG::CompositeCoder
This is the base class for all type cast classes of PostgreSQL types, that are made up of some sub type.
Attributes
Public Instance Methods
Source
static VALUE
pg_coder_delimiter_get(VALUE self)
{
t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
return rb_str_new(&this->delimiter, 1);
}
The character that separates values within the composite type.
Source
static VALUE
pg_coder_delimiter_set(VALUE self, VALUE delimiter)
{
t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
StringValue(delimiter);
if(RSTRING_LEN(delimiter) != 1)
rb_raise( rb_eArgError, "delimiter size must be one byte");
this->delimiter = *RSTRING_PTR(delimiter);
return delimiter;
}
Specifies the character that separates values within the composite type. The default is a comma. This must be a single one-byte character.
Source
static VALUE
pg_coder_elements_type_set(VALUE self, VALUE elem_type)
{
t_pg_composite_coder *this = RTYPEDDATA_DATA( self );
if ( NIL_P(elem_type) ){
this->elem = NULL;
} else if ( rb_obj_is_kind_of(elem_type, rb_cPG_Coder) ){
this->elem = RTYPEDDATA_DATA( elem_type );
} else {
rb_raise( rb_eTypeError, "wrong elements type %s (expected some kind of PG::Coder)",
rb_obj_classname( elem_type ) );
}
rb_iv_set( self, "@elements_type", elem_type );
return elem_type;
}
Specifies the PG::Coder object that is used to encode or decode the single elementes of this composite type.
If set to nil all values are encoded and decoded as String objects.
Source
# File lib/pg/coder.rb, line 79 def inspect str = super str[-1,0] = " elements_type=#{elements_type.inspect} #{needs_quotation? ? 'needs' : 'no'} quotation" str end
PG::Coder#inspect
Source
static VALUE
pg_coder_needs_quotation_set(VALUE self, VALUE needs_quotation)
{
t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
this->needs_quotation = RTEST(needs_quotation);
return needs_quotation;
}
Specifies whether the assigned elements_type requires quotation marks to be transferred safely. Encoding with needs_quotation=false is somewhat faster.
The default is true. This option is ignored for decoding of values.
Source
static VALUE
pg_coder_needs_quotation_get(VALUE self)
{
t_pg_composite_coder *this = RTYPEDDATA_DATA(self);
return this->needs_quotation ? Qtrue : Qfalse;
}
Specifies whether the assigned elements_type requires quotation marks to be transferred safely.
Source
# File lib/pg/coder.rb, line 71 def to_h super.merge!({ elements_type: elements_type, needs_quotation: needs_quotation?, delimiter: delimiter, }) end
PG::Coder#to_h