# encoding: utf-8 require 'dm-core' require 'dm-types/support/dirty_minder' module DataMapper class Property class PgJSON include ::DataMapper::Property::DirtyMinder def dump(value) case value when ::NilClass, ::String value when ::Hash, ::Array Oj.dump(value, mode: :compat) else '{}' end end def load(value) case value when ::Hash, ::Array value when ::String Oj.load(value) else nil end end def primitive?(value) value = load(value) if value.kind_of?(::String) value.kind_of?(::Array) || value.kind_of?(::Hash) end end end end