class Rasti::DB::TypeConverters::PostgresTypes::Array

Constants

DB_TYPE_REGEX

Public Class Methods

from_db(value) click to toggle source
# File lib/rasti/db/type_converters/postgres_types/array.rb, line 25
def from_db(value)
  value.to_a
end
from_db?(klass) click to toggle source
# File lib/rasti/db/type_converters/postgres_types/array.rb, line 20
def from_db?(klass)
  defined?(Sequel::Postgres::PGArray) &&
  klass == Sequel::Postgres::PGArray
end
to_db(value, type) click to toggle source
# File lib/rasti/db/type_converters/postgres_types/array.rb, line 14
def to_db(value, type)
  sub_type = type[0..-3]
  array = sub_type == 'hstore' ? value.map { |v| Sequel.hstore v } : value
  Sequel.pg_array array, sub_type
end
to_db?(type) click to toggle source
# File lib/rasti/db/type_converters/postgres_types/array.rb, line 10
def to_db?(type)
  !type.match(DB_TYPE_REGEX).nil?
end