| Module | WDDX |
| In: |
lib/wddx.rb
lib/wddx/core_ext.rb lib/wddx/deserializer.rb lib/wddx/record_set.rb lib/wddx/serializer.rb lib/wddx/struct.rb lib/wddx/wddx_packet.rb |
$Id: wddx_packet.rb 94 2006-12-24 13:05:36Z stefan $ Created by Stefan Saasen. Copyright (c) 2006. All rights reserved.
| PACKET_VERSION | = | 1.0 |
| open | -> | load |
| from_file | -> | file |
Deserialize WDDX-XML to a WDDX::WddxPacket
p = WDDX.deserialize(xml_string) p.data # => String, Number, Time...
The method dump tries to serialize arbitrary Ruby objects.
print WDDX.dump("Hello world") # => "<wddxPacket version='1.0'><header/><data><string>Hello world</string></data></wddxPacket>"
You can add a to_wddx_properties method to your class that returns an array of fields an method names (as symbol) that will be serialized as WDDX XML.
class MyObj
def initilize(name, price)
@name, @price = name, price
end
def custom_price; @price * 1.05; end
def to_wddx_properties
["@name", :custom_price]
end
end
WDDX.dump(MyObj.new("Klaus Tester", 123))