Class | Sequel::Postgres::HStore::Parser |
In: |
lib/sequel/extensions/pg_hstore.rb
|
Parent: | StringScanner |
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(/"/) 107: k = parse_quoted 108: skip(/"\s*=>\s*/) 109: if skip(/"/) 110: v = parse_quoted 111: skip(/"/) 112: else 113: scan(/NULL/) 114: v = nil 115: end 116: skip(/,\s*/) 117: hash[k] = v 118: end 119: @result = hash 120: end