def deserialize(value)
        case value
        when String
          payload = ActiveSupport::JSON.decode(value) rescue {}
          model_instance(deserialize_by_types(payload))
        when Hash
          model_instance(deserialize_by_types(value))
        when nil
          nil
        else raise_cast_error(value)
        end
      end
Converts a value from database input to the appropriate ruby type.

@param value [String] value to deserialize

@return [Object] deserialized value
rubocop:disable Style/RescueModifier