Sha256: a1519d219a13dbd2c526149b5120bfbf4ddd9efcbb537e9d26238c6c7d31d19a

Contents?: true

Size: 794 Bytes

Versions: 13

Compression:

Stored size: 794 Bytes

Contents

module Rasti
  module DB
    module TypeConverters
      module PostgresTypes
        class JSON

          class << self

            def column_type_regex
              /^json$/
            end

            def to_db(value, sub_type)
              Sequel.pg_json 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::JSONHash => :to_h,
                Sequel::Postgres::JSONArray => :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/json.rb
rasti-db-2.2.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-2.1.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-2.0.1 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-2.0.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.5.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.4.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.3.1 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.3.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.2.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.1.1 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.1.0 lib/rasti/db/type_converters/postgres_types/json.rb
rasti-db-1.0.0 lib/rasti/db/type_converters/postgres_types/json.rb