lib/odata4/entity.rb in odata4-0.8.0 vs lib/odata4/entity.rb in odata4-0.8.1

- old
+ new

@@ -167,11 +167,11 @@ # @return [String] def to_xml namespaces = XML_NAMESPACES.merge('xml:base' => service.service_url) builder = Nokogiri::XML::Builder.new do |xml| xml.entry(namespaces) do - xml.category(term: "#{namespace}.#{type}", + xml.category(term: type, scheme: 'http://docs.oasis-open.org/odata/ns/scheme') xml.author { xml.name } xml.content(type: 'application/xml') do xml['metadata'].properties do @@ -234,16 +234,24 @@ end private def instantiate_property(property_name, value_xml) - value_type = schema.get_property_type(name, property_name) - klass = ::OData4::PropertyRegistry[value_type] + prop_type = schema.get_property_type(name, property_name) + prop_type, value_type = prop_type.split(/\(|\)/) + if prop_type == 'Collection' + klass = ::OData4::Properties::Collection + options = { value_type: value_type } + else + klass = ::OData4::PropertyRegistry[prop_type] + options = {} + end + if klass.nil? - raise RuntimeError, "Unknown property type: #{value_type}" + raise RuntimeError, "Unknown property type: #{prop_type}" else - klass.from_xml(value_xml, service: service) + klass.from_xml(value_xml, options.merge(service: service)) end end def properties @properties ||= {}