Skip to content

Commit 0c850b3

Browse files
committed
Add missing documentation to some coder classes
... and mention that they require extensions on first use.
1 parent 0ac827c commit 0c850b3

File tree

8 files changed

+20
-0
lines changed

8 files changed

+20
-0
lines changed

ext/pg_binary_decoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ j2date(int jd, int *year, int *month, int *day)
233233
*
234234
* This is a decoder class for conversion of PostgreSQL binary date
235235
* to Ruby Date objects.
236+
*
237+
* As soon as this class is used, it requires the ruby standard library 'date'.
236238
*/
237239
static VALUE
238240
pg_bin_dec_date(t_pg_coder *conv, const char *val, int len, int tuple, int field, int enc_idx)

ext/pg_text_decoder.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ pg_text_dec_integer(t_pg_coder *conv, const char *val, int len, int tuple, int f
163163
* This is a decoder class for conversion of PostgreSQL numeric types
164164
* to Ruby BigDecimal objects.
165165
*
166+
* As soon as this class is used, it requires the 'bigdecimal' gem.
167+
*
166168
*/
167169
static VALUE
168170
pg_text_dec_numeric(t_pg_coder *conv, const char *val, int len, int tuple, int field, int enc_idx)
@@ -811,6 +813,7 @@ static VALUE pg_text_dec_timestamp(t_pg_coder *conv, const char *val, int len, i
811813
* This is a decoder class for conversion of PostgreSQL inet type
812814
* to Ruby IPAddr values.
813815
*
816+
* As soon as this class is used, it requires the ruby standard library 'ipaddr'.
814817
*/
815818
static VALUE
816819
pg_text_dec_inet(t_pg_coder *conv, const char *val, int len, int tuple, int field, int enc_idx)

ext/pg_text_encoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ pg_text_enc_float(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate,
345345
*
346346
* It converts Integer, Float and BigDecimal objects.
347347
* All other objects are expected to respond to +to_s+.
348+
*
349+
* As soon as this class is used, it requires the 'bigdecimal' gem.
348350
*/
349351
static int
350352
pg_text_enc_numeric(t_pg_coder *this, VALUE value, char *out, VALUE *intermediate, int enc_idx)

lib/pg/text_decoder/date.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
module PG
77
module TextDecoder
8+
# This is a decoder class for conversion of PostgreSQL date type to Ruby Date values.
9+
#
10+
# As soon as this class is used, it requires the ruby standard library 'date'.
811
class Date < SimpleDecoder
912
def decode(string, tuple=nil, field=nil)
1013
if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/

lib/pg/text_decoder/json.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
module PG
77
module TextDecoder
8+
# This is a decoder class for conversion of PostgreSQL JSON/JSONB type to Ruby Hash, Array, String, Numeric, nil values.
9+
#
10+
# As soon as this class is used, it requires the ruby standard library 'json'.
811
class JSON < SimpleDecoder
912
def decode(string, tuple=nil, field=nil)
1013
::JSON.parse(string, quirks_mode: true)

lib/pg/text_encoder/date.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
module PG
55
module TextEncoder
6+
# This is a encoder class for conversion of Ruby Date values to PostgreSQL date type.
67
class Date < SimpleEncoder
78
def encode(value)
89
value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value

lib/pg/text_encoder/inet.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
module PG
77
module TextEncoder
8+
# This is a encoder class for conversion of Ruby IPAddr values to PostgreSQL inet type.
9+
#
10+
# As soon as this class is used, it requires the ruby standard library 'ipaddr'.
811
class Inet < SimpleEncoder
912
def encode(value)
1013
case value

lib/pg/text_encoder/json.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
module PG
77
module TextEncoder
8+
# This is a encoder class for conversion of Ruby Hash, Array, String, Numeric, nil values to PostgreSQL JSON/JSONB type.
9+
#
10+
# As soon as this class is used, it requires the ruby standard library 'json'.
811
class JSON < SimpleEncoder
912
def encode(value)
1013
::JSON.generate(value, quirks_mode: true)

0 commit comments

Comments
 (0)