Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support serializing managed and data objects to anyType fields

  • Loading branch information...
commit ad5a17a5a7497bea747d46267de668a29a8d2655 1 parent ae36316
Rich Lane authored
Showing with 18 additions and 2 deletions.
  1. +2 −2 lib/rbvmomi/connection.rb
  2. +16 −0 test/test_serialization.rb
View
4 lib/rbvmomi/connection.rb
@@ -132,10 +132,10 @@ def obj2xml xml, name, type, is_array, o, attrs={}
end
end
when BasicTypes::ManagedObject
- fail "expected #{expected.wsdl_name}, got #{o.class.wsdl_name} for field #{name.inspect}" if expected and not expected >= o.class
+ fail "expected #{expected.wsdl_name}, got #{o.class.wsdl_name} for field #{name.inspect}" if expected and not expected >= o.class and not expected == BasicTypes::AnyType
xml.tag! name, o._ref, :type => o.class.wsdl_name
when BasicTypes::DataObject
- fail "expected #{expected.wsdl_name}, got #{o.class.wsdl_name} for field #{name.inspect}" if expected and not expected >= o.class
+ fail "expected #{expected.wsdl_name}, got #{o.class.wsdl_name} for field #{name.inspect}" if expected and not expected >= o.class and not expected == BasicTypes::AnyType
xml.tag! name, attrs.merge("xsi:type" => o.class.wsdl_name) do
o.class.full_props_desc.each do |desc|
if o.props.member? desc['name'].to_sym
View
16 test/test_serialization.rb
@@ -292,4 +292,20 @@ def test_time
<root>2011-11-16T13:36:08-08:00</root>
EOS
end
+
+ # TODO test all types
+ def test_any_type
+ obj = 1
+ check <<-EOS, obj, 'xsd:anyType', false
+<root xsi:type="xsd:long">1</root>
+ EOS
+
+ obj = VIM::HostAccountSpec(:id => 'root', :password => 'foo')
+ check <<-EOS, obj, 'xsd:anyType', false
+<root xsi:type="HostAccountSpec">
+ <id>root</id>
+ <password>foo</password>
+</root>
+ EOS
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.