lib/hexapdf/dictionary.rb in hexapdf-0.9.3 vs lib/hexapdf/dictionary.rb in hexapdf-0.10.0
- old
+ new
@@ -282,11 +282,20 @@
# The checks below assume that the field has a value
next if obj.nil?
# Check the type of the field
unless field.valid_object?(obj)
- yield("Type of field #{name} is invalid: #{obj.class}", false)
+ msg = "Type of field #{name} is invalid: #{obj.class}"
+ if field.type.include?(String) && obj.kind_of?(Symbol)
+ yield(msg, true)
+ self[name] = obj.to_s
+ elsif field.type.include?(Symbol) && obj.kind_of?(String)
+ yield(msg, true)
+ self[name] = obj.intern
+ else
+ yield(msg, false)
+ end
end
# Check if field value needs to be (in)direct
unless field.indirect.nil?
obj = value[name] # we need the unwrapped object!
@@ -300,8 +309,13 @@
end
end
end
end
+ end
+
+ # :nodoc:
+ # Forward declaration of Stream to circumvent circular require problem
+ class Stream < Dictionary
end
end