Parent

Class Index [+]

Quicksearch

Sequel::Postgres::HStore::Parser

Parser for PostgreSQL hstore output format.

Constants

QUOTE_RE
KV_SEP_RE
NULL_RE
SEP_RE
QUOTED_RE
REPLACE_RE
REPLACE_WITH

Public Instance Methods

parse() click to toggle source

Parse the output format that PostgreSQL uses for hstore columns. Note that this does not attempt to parse all input formats that PostgreSQL will accept. For instance, it expects all keys and non-NULL values to be quoted.

Return the resulting hash of objects. This can be called multiple times, it will cache the parsed hash on the first call and use it for subsequent calls.

     # File lib/sequel/extensions/pg_hstore.rb, line 102
102:         def parse
103:           return @result if @result
104:           hash = {}
105:           while !eos?
106:             skip(QUOTE_RE)
107:             k = parse_quoted
108:             skip(KV_SEP_RE)
109:             if skip(QUOTE_RE)
110:               v = parse_quoted
111:               skip(QUOTE_RE)
112:             else
113:               scan(NULL_RE)
114:               v = nil
115:             end
116:             skip(SEP_RE)
117:             hash[k] = v
118:           end
119:           @result = hash
120:         end

Private Instance Methods

parse_quoted() click to toggle source

Parse and unescape a quoted key/value.

     # File lib/sequel/extensions/pg_hstore.rb, line 125
125:         def parse_quoted
126:           scan(QUOTED_RE).gsub(REPLACE_RE, REPLACE_WITH)
127:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.