Module: ROM::SQL::Postgres::Types::ArrayMethods

Defined in:
lib/rom/sql/extensions/postgres/types/array.rb

Instance Method Summary collapse

Instance Method Details

#+(type, expr, other) ⇒ Object



149
150
151
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 149

def +(type, expr, other)
  Attribute[type].meta(sql_expr: expr.pg_array.concat(other))
end

#any(_type, expr, value) ⇒ Object



125
126
127
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 125

def any(_type, expr, value)
  Attribute[SQL::Types::Bool].meta(sql_expr: { value => expr.pg_array.any })
end

#contain(type, expr, other) ⇒ Object



117
118
119
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 117

def contain(type, expr, other)
  Attribute[SQL::Types::Bool].meta(sql_expr: expr.pg_array.contains(type[other]))
end

#contained_by(type, expr, other) ⇒ Object



129
130
131
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 129

def contained_by(type, expr, other)
  Attribute[SQL::Types::Bool].meta(sql_expr: expr.pg_array.contained_by(type[other]))
end

#get(type, expr, idx) ⇒ Object



121
122
123
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 121

def get(type, expr, idx)
  Attribute[type].meta(sql_expr: expr.pg_array[idx])
end

#join(_type, expr, delimiter = '', null = nil) ⇒ Object



145
146
147
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 145

def join(_type, expr, delimiter = '', null = nil)
  Attribute[SQL::Types::String].meta(sql_expr: expr.pg_array.join(delimiter, null))
end

#length(_type, expr) ⇒ Object



133
134
135
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 133

def length(_type, expr)
  Attribute[SQL::Types::Integer].meta(sql_expr: expr.pg_array.length)
end

#overlaps(type, expr, other_array) ⇒ Object



137
138
139
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 137

def overlaps(type, expr, other_array)
  Attribute[SQL::Types::Bool].meta(sql_expr: expr.pg_array.overlaps(type[other_array]))
end

#remove_value(type, expr, value) ⇒ Object



141
142
143
# File 'lib/rom/sql/extensions/postgres/types/array.rb', line 141

def remove_value(type, expr, value)
  Attribute[type].meta(sql_expr: expr.pg_array.remove(cast(type, value)))
end