Sha256: 1671dc95655cabeae1f542a4213bf1dae61d5ff624094c192a14cd71f3442f91

Contents?: true

Size: 799 Bytes

Versions: 13

Compression:

Stored size: 799 Bytes

Contents

module Rasti
  module DB
    module TypeConverters
      module PostgresTypes
        class JSONB

          class << self

            def column_type_regex
              /^jsonb$/
            end

            def to_db(value, sub_type)
              Sequel.pg_jsonb value
            end

            def db_classes
              @db_classes ||= from_db_convertions.keys
            end

            def from_db(object)
              object.public_send from_db_convertions[object.class]
            end

            private

            def from_db_convertions
              @from_db_convertions ||= {
                Sequel::Postgres::JSONBHash => :to_h,
                Sequel::Postgres::JSONBArray => :to_a
              }
            end

          end

        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rasti-db-2.3.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-2.2.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-2.1.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-2.0.1 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-2.0.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.5.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.4.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.3.1 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.3.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.2.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.1.1 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.1.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb
rasti-db-1.0.0 lib/rasti/db/type_converters/postgres_types/jsonb.rb