lib/hexapdf/dictionary.rb in hexapdf-0.7.0 vs lib/hexapdf/dictionary.rb in hexapdf-0.8.0
- old
+ new
@@ -76,10 +76,14 @@
# classes.
#
# If a Symbol object instead of a class is provided, the class is looked up using the
# 'object.type_map' global configuration option when necessary to support lazy loading.
#
+ # Note that if multiple types are allowed and one of the allowed types is Dictionary (or
+ # a Symbol), it has to be the first in the list. Otherwise automatic type conversion
+ # functions won't work correctly.
+ #
# required:: Specifies whether this field is required.
#
# default:: Specifies the default value for the field, if any.
#
# indirect:: Specifies whether the value (or the values in the array value) of this field has
@@ -154,10 +158,12 @@
end
value[name] = data = document.deref(data) if data.kind_of?(HexaPDF::Reference)
if data.class == HexaPDF::Object || (data.kind_of?(HexaPDF::Object) && data.value.nil?)
data = data.value
end
- self[name] = data = field.convert(data, document) if field&.convert?(data)
+ if (result = field&.convert(data, document))
+ self[name] = data = result
+ end
data
end
# Stores the data under name in the dictionary. Name has to be a Symbol object.
#