Unmapped values are taken into account in the object mapping size.

dev
Karchnu 2020-11-11 00:45:59 +01:00
parent 94f47dd728
commit 4ac38a7598
1 changed files with 9 additions and 0 deletions

View File

@ -244,6 +244,10 @@ module CBOR
raise ::CBOR::SerializationError.new("Unknown CBOR attribute: #{key}", self.class.to_s, nil)
end
protected def get_cbor_unmapped
{} of String => ::CBOR::Type
end
protected def on_to_cbor(cbor : ::CBOR::Encoder)
end
@ -283,6 +287,7 @@ module CBOR
{% end %} # macro unless value[:emit_null]
{% end %} # macro for properties
nb_properties_to_serialize += get_cbor_unmapped.size
{% if properties.size > 0 %}
@ -329,6 +334,10 @@ module CBOR
end
end
protected def get_cbor_unmapped
cbor_unmapped
end
protected def on_to_cbor(cbor : ::CBOR::Encoder)
cbor_unmapped.each do |key, value|
cbor.write(key)