Class Index [+]

Quicksearch

Sequel::Postgres::HStoreOp

The HStoreOp class is a simple container for a single object that defines methods that yield Sequel expression objects representing PostgreSQL hstore operators and functions.

In the method documentation examples, assume that:

  hstore_op = :hstore.hstore

Constants

CONCAT
CONTAIN_ALL
CONTAIN_ANY
CONTAINS
CONTAINED_BY
HAS_KEY
LOOKUP
RECORD_SET

Public Instance Methods

-(other) click to toggle source

Delete entries from an hstore using the subtraction operator:

  hstore_op - 'a' # (hstore - 'a')
    # File lib/sequel/extensions/pg_hstore_ops.rb, line 63
63:       def -(other)
64:         HStoreOp.new(super)
65:       end
[](key) click to toggle source

Lookup the value for the given key in an hstore:

  hstore_op['a'] # (hstore -> 'a')
    # File lib/sequel/extensions/pg_hstore_ops.rb, line 70
70:       def [](key)
71:         Sequel::SQL::StringExpression.new(:NOOP, Sequel::SQL::PlaceholderLiteralString.new(LOOKUP, [value, key]))
72:       end
akeys() click to toggle source
Alias for: keys
avals() click to toggle source
Alias for: values
concat(other) click to toggle source
Alias for: merge
contain_all(other) click to toggle source

Check if the receiver contains all of the keys in the given array:

  hstore_op.contain_all(:a) # (hstore ?& a)
    # File lib/sequel/extensions/pg_hstore_ops.rb, line 77
77:       def contain_all(other)
78:         bool_op(CONTAIN_ALL, other)
79:       end
contain_any(other) click to toggle source

Check if the receiver contains any of the keys in the given array:

  hstore_op.contain_any(:a) # (hstore ?| a)
    # File lib/sequel/extensions/pg_hstore_ops.rb, line 84
84:       def contain_any(other)
85:         bool_op(CONTAIN_ANY, other)
86:       end
contained_by(other) click to toggle source

Check if the other hstore contains all entries in the receiver:

  hstore_op.contained_by(:h) # (hstore <@ h)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 98
 98:       def contained_by(other)
 99:         bool_op(CONTAINED_BY, other)
100:       end
contains(other) click to toggle source

Check if the receiver contains all entries in the other hstore:

  hstore_op.contains(:h) # (hstore @> h)
    # File lib/sequel/extensions/pg_hstore_ops.rb, line 91
91:       def contains(other)
92:         bool_op(CONTAINS, other)
93:       end
defined(key) click to toggle source

Check if the receiver contains a non-NULL value for the given key:

  hstore_op.defined('a') # defined(hstore, 'a')
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 105
105:       def defined(key)
106:         Sequel::SQL::BooleanExpression.new(:NOOP, function(:defined, key))
107:       end
delete(key) click to toggle source

Delete the matching entries from the receiver:

  hstore_op.delete('a') # delete(hstore, 'a')
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 112
112:       def delete(key)
113:         HStoreOp.new(function(:delete, key))
114:       end
each() click to toggle source

Transform the receiver into a set of keys and values:

  hstore_op.each # each(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 119
119:       def each
120:         function(:each)
121:       end
exist?(key) click to toggle source
Alias for: has_key?
has_key?(key) click to toggle source

Check if the receiver contains the given key:

  hstore_op.has_key?('a') # (hstore ? 'a')
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 126
126:       def has_key?(key)
127:         bool_op(HAS_KEY, key)
128:       end
Also aliased as: include?, key?, member?, exist?
hstore() click to toggle source

Return the receiver.

     # File lib/sequel/extensions/pg_hstore_ops.rb, line 135
135:       def hstore
136:         self
137:       end
include?(key) click to toggle source
Alias for: has_key?
key?(key) click to toggle source
Alias for: has_key?
keys() click to toggle source

Return the keys as a PostgreSQL array:

  hstore_op.keys # akeys(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 142
142:       def keys
143:         function(:akeys)
144:       end
Also aliased as: akeys
member?(key) click to toggle source
Alias for: has_key?
merge(other) click to toggle source

Merge a given hstore into the receiver:

  hstore_op.merge(:a) # (hstore || a)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 150
150:       def merge(other)
151:         HStoreOp.new(Sequel::SQL::PlaceholderLiteralString.new(CONCAT, [self, other]))
152:       end
Also aliased as: concat
populate(record) click to toggle source

Create a new record populated with entries from the receiver:

  hstore_op.populate(:a) # populate_record(a, hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 158
158:       def populate(record)
159:         SQL::Function.new(:populate_record, record, self)
160:       end
record_set(record) click to toggle source

Update the values in a record using entries in the receiver:

  hstore_op.record_set(:a) # (a #= hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 165
165:       def record_set(record)
166:         Sequel::SQL::PlaceholderLiteralString.new(RECORD_SET, [record, value])
167:       end
skeys() click to toggle source

Return the keys as a PostgreSQL set:

  hstore_op.skeys # skeys(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 172
172:       def skeys
173:         function(:skeys)
174:       end
slice(keys) click to toggle source

Return an hstore with only the keys in the given array:

  hstore_op.slice(:a) # slice(hstore, a)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 179
179:       def slice(keys)
180:         HStoreOp.new(function(:slice, keys))
181:       end
svals() click to toggle source

Return the values as a PostgreSQL set:

  hstore_op.svals # svals(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 186
186:       def svals
187:         function(:svals)
188:       end
to_array() click to toggle source

Return a flattened array of the receiver with alternating keys and values:

  hstore_op.to_array # hstore_to_array(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 194
194:       def to_array
195:         function(:hstore_to_array)
196:       end
to_matrix() click to toggle source

Return a nested array of the receiver, with arrays of 2 element (key/value) arrays:

  hstore_op.to_matrix # hstore_to_matrix(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 202
202:       def to_matrix
203:         function(:hstore_to_matrix)
204:       end
values() click to toggle source

Return the values as a PostgreSQL array:

  hstore_op.values # avals(hstore)
     # File lib/sequel/extensions/pg_hstore_ops.rb, line 209
209:       def values
210:         function(:avals)
211:       end
Also aliased as: avals

Private Instance Methods

bool_op(str, other) click to toggle source

Return a placeholder literal with the given str and args, wrapped in a boolean expression, used by operators that return booleans.

     # File lib/sequel/extensions/pg_hstore_ops.rb, line 218
218:       def bool_op(str, other)
219:         Sequel::SQL::BooleanExpression.new(:NOOP, Sequel::SQL::PlaceholderLiteralString.new(str, [value, other]))
220:       end
function(name, *args) click to toggle source

Return a function with the given name, and the receiver as the first argument, with any additional arguments given.

     # File lib/sequel/extensions/pg_hstore_ops.rb, line 224
224:       def function(name, *args)
225:         SQL::Function.new(name, self, *args)
226:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.