Sha256: 713a1f3e62addd715993ffbf3e2cdf5143a868aeddffc4d3766132649435b4e1
Contents?: true
Size: 938 Bytes
Versions: 8
Compression:
Stored size: 938 Bytes
Contents
module Rasti module DB module TypeConverters module PostgresTypes class JSONB class << self DB_TYPE_REGEX = /^jsonb$/ def to_db?(type) !type.match(DB_TYPE_REGEX).nil? end def to_db(value, type) Sequel.pg_jsonb value end def from_db?(klass) to_hash?(klass) || to_array?(klass) end def from_db(value) to_hash?(value.class) ? value.to_h : value.to_a end private def to_hash?(klass) defined?(Sequel::Postgres::JSONBHash) && klass == Sequel::Postgres::JSONBHash end def to_array?(klass) defined?(Sequel::Postgres::JSONBArray) && klass == Sequel::Postgres::JSONBArray end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems