Class Sequel::Postgres::PGArray::JSONCreator
In: lib/sequel/extensions/pg_array.rb
Parent: Creator

Callable object that takes the input string and parses it using. a JSON parser. This should be faster than the standard Creator, but only handles integer types correctly.

Methods

call  

Constants

SUBST = {'{'.freeze=>'['.freeze, '}'.freeze=>']'.freeze, 'NULL'.freeze=>'null'.freeze}   Character conversion map mapping input strings to JSON replacements
SUBST_RE = %r[\{|\}|NULL].freeze   Regular expression matching input strings to convert

Public Instance methods

Parse the input string by using a gsub to convert non-JSON characters to JSON, running it through a regular JSON parser. If a converter is used, a recursive map of the output is done to make sure that the entires in the correct type.

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 430
430:         def call(string)
431:           array = JSON.parse(string.gsub(SUBST_RE){|m| SUBST[m]})
432:           array = Sequel.recursive_map(array, @converter) if @converter
433:           PGArray.new(array, @type)
434:         end

[Validate]