Serialize an object, with full serialization or a simple reference

Property definitions

serialization $ Serializer :: serialize_reference
	# Serialize an object, with full serialization or a simple reference
	protected fun serialize_reference(object: Serializable) is abstract
lib/serialization/serialization_core.nit:68,2--69,68

serialization $ InspectSerializer :: serialize_reference
	redef fun serialize_reference(object)
	do
		if cache.has_object(object) then
			# Cycle
			var id = object.object_id
			if inspect_testing then id = cache.id_for(object)

			stream.write "<"
			stream.write object.class_name
			stream.write "#"
			stream.write id.to_s
			stream.write ">"
		else if object != first_object and (not object isa DirectSerializable) then
			# Another object, print class and id only
			var id = object.object_id
			if inspect_testing then id = cache.new_id_for(object)

			stream.write "<"
			stream.write object.class_name
			stream.write "#"
			stream.write id.to_s
			stream.write ">"
		else
			# Main object
			serialize object
		end
	end
lib/serialization/inspect.nit:67,2--93,4

json $ JsonSerializer :: serialize_reference
	redef fun serialize_reference(object)
	do
		if not plain_json and cache.has_object(object) then
			# if already serialized, add local reference
			var id = cache.id_for(object)
			stream.write "\{"
			indent_level += 1
			new_line_and_indent
			stream.write "\"__kind\": \"ref\", \"__id\": "
			stream.write id.to_s
			indent_level -= 1
			new_line_and_indent
			stream.write "\}"
		else
			# serialize here
			serialize object
		end
	end
lib/json/serialization_write.nit:118,2--135,4

msgpack $ MsgPackSerializer :: serialize_reference
	redef fun serialize_reference(object)
	do
		if not plain_msgpack and cache.has_object(object) then
			# if already serialized, add local reference
			var id = cache.id_for(object)
			stream.write_msgpack_ext(ext_typ_ref, id.to_bytes)
		else
			# serialize
			serialize object
		end
	end
lib/msgpack/serialization_write.nit:117,2--127,4

popcorn $ RepoSerializer :: serialize_reference
	# Remove caching when saving refs to db
	redef fun serialize_reference(object) do serialize object
lib/popcorn/pop_repos.nit:249,2--250,58