Parent

Class Index [+]

Quicksearch

Sequel::Postgres::HStore

Constants

DEFAULT_PROC

Default proc used for all underlying HStore hashes, so that even if you grab the underlying hash, it will still convert non-string keys to strings during lookup.

QUOTE
COMMA
KV_SEP
NULL
ESCAPE_RE
ESCAPE_REPLACE
HSTORE_CAST

Public Class Methods

parse(str) click to toggle source

Parse the given string into an HStore, assuming the str is in PostgreSQL hstore output format.

     # File lib/sequel/extensions/pg_hstore.rb, line 189
189:       def self.parse(str)
190:         new(Parser.new(str).parse)
191:       end

Public Instance Methods

fetch(key, *args, &block) click to toggle source

Override to force the key argument to a string.

     # File lib/sequel/extensions/pg_hstore.rb, line 215
215:       def fetch(key, *args, &block)
216:         super(key.to_s, *args, &block)
217:       end
merge(hash, &block) click to toggle source

Convert the input hash to string keys and values before merging, and return a new HStore instance with the merged hash.

     # File lib/sequel/extensions/pg_hstore.rb, line 221
221:       def merge(hash, &block)
222:         self.class.new(super(convert_hash(hash), &block))
223:       end
op() click to toggle source

Wrap the receiver in an HStoreOp so you can easily use the PostgreSQL hstore functions and operators with it.

     # File lib/sequel/extensions/pg_hstore_ops.rb, line 241
241:         def op
242:           HStoreOp.new(self)
243:         end
sql_literal_append(ds, sql) click to toggle source

Append a literalize version of the hstore to the sql.

     # File lib/sequel/extensions/pg_hstore.rb, line 229
229:       def sql_literal_append(ds, sql)
230:         ds.literal_append(sql, unquoted_literal)
231:         sql << HSTORE_CAST
232:       end
unquoted_literal() click to toggle source

Return a string containing the unquoted, unstring-escaped literal version of the hstore. Separated out for use by the bound argument code.

     # File lib/sequel/extensions/pg_hstore.rb, line 237
237:       def unquoted_literal
238:         str = ''
239:         comma = false
240:         commas = COMMA
241:         quote = QUOTE
242:         kv_sep = KV_SEP
243:         null = NULL
244:         each do |k, v|
245:           str << commas if comma
246:           str << quote << escape_value(k) << quote
247:           str << kv_sep
248:           if v.nil?
249:             str << null
250:           else
251:             str << quote << escape_value(v) << quote
252:           end
253:           comma = true
254:         end
255:         str
256:       end

Private Instance Methods

convert_hash(h) click to toggle source

Return a new hash based on the input hash with string keys and string or nil values.

     # File lib/sequel/extensions/pg_hstore.rb, line 262
262:       def convert_hash(h)
263:         hash = Hash.new(&DEFAULT_PROC)
264:         h.each{|k,v| hash[k.to_s] = convert_value(v)}
265:         hash
266:       end
convert_value(v) click to toggle source

Return value v as a string unless it is already nil.

     # File lib/sequel/extensions/pg_hstore.rb, line 269
269:       def convert_value(v)
270:         v.to_s unless v.nil?
271:       end
escape_value(k) click to toggle source

Escape key/value strings when literalizing to correctly handle backslash and quote characters.

     # File lib/sequel/extensions/pg_hstore.rb, line 275
275:       def escape_value(k)
276:         k.to_s.gsub(ESCAPE_RE, ESCAPE_REPLACE)
277:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.