Serialize an attribute to compose a serializable object

This method should be called from Serializable::core_serialize_to.

Property definitions

serialization $ Serializer :: serialize_attribute
	# Serialize an attribute to compose a serializable object
	#
	# This method should be called from `Serializable::core_serialize_to`.
	fun serialize_attribute(name: String, value: nullable Object)
	do
		if not try_to_serialize(value) then
			assert value != null # null would have been serialized
			warn("argument {name} of type {value.class_name} is not serializable.")
		end
	end
lib/serialization/serialization_core.nit:71,2--80,4

msgpack $ AttributeCounter :: serialize_attribute
	redef fun serialize_attribute(name, object) do count += 1
lib/msgpack/serialization_write.nit:158,2--58

serialization $ RestrictedSerializer :: serialize_attribute
	# This method is called when trying to serialize a specific attribute
	redef fun serialize_attribute(name, value)
	do
		var recv = current_object
		if recv isa E then
			# do not serialize `E::semi_private`
			if name == "semi_private" then return
		end

		if value isa E then
			# Do not serialize references to `E`.
			# Just use a domain-specific value that make sense in the business logic.
			serialize_attribute(name, "ID:" + value.id)
			return
		end

		super
	end
lib/serialization/examples/custom_serialization.nit:104,2--121,4

msgpack $ MsgPackSerializer :: serialize_attribute
	redef fun serialize_attribute(name, value)
	do
		serialize_meta_string name
		super
	end
lib/msgpack/serialization_write.nit:111,2--115,4