PGArray subclass handling integer and float types, using a fast JSON parser. Does not handle numeric/decimal types, since JSON does deal with arbitrary precision (see PGDecimalArray for that).
Parse the input string by using a gsub to convert non-JSON characters to JSON, running it through a regular JSON parser, and the doing a recursive map over the output to make sure the entries are in the correct type (mostly, to make sure real/double precision database types are returned as float and not integer).
# File lib/sequel/extensions/pg_array.rb, line 349 349: def self.parse(string, type=nil) 350: new(recursive_map(JSON.parse(string.gsub(SUBST_RE){|m| SUBST[m]})), type) 351: end
Convert each item in the array to the correct type, handling multi-dimensional arrays.
# File lib/sequel/extensions/pg_array.rb, line 355 355: def self.recursive_map(array) 356: array.map do |i| 357: if i.is_a?(Array) 358: recursive_map(i) 359: elsif i 360: convert_item(i) 361: end 362: end 363: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.