From: <pop...@fr...> - 2006-03-03 22:17:49
|
Hi. I try to use Yaml to store gnomecanvas items, where a group item has=20 other items, that refer to the group, but the=20 object created in my YAML::add_domain_type gets lost and instead of=20 that I get an other one from YAML. A simple self-reference is enough for the same phenomena. require "yaml" class Foo attr_accessor :point =20 def to_yaml_type =09"!Foo,2006/Foo" end end YAML::add_domain_type( 'Foo,2006', 'Foo' ) do |type, val| obj =3D Foo.new obj.point =3D obj p "object created in add_domain_type " + obj.inspect obj end #create an object with self ref myFoo =3D Foo.new myFoo.point =3D myFoo yaml_Foo =3D myFoo.to_yaml p yaml_Foo =20 restored_obj =3D YAML::load(yaml_Foo) p "restored_obj " + restored_obj.inspect the output: "--- &id001 !Foo,2006/Foo \npoint: *id001\n" "object created in add_domain_type #<Foo:0x402cb1f8 @point=3D#<Foo: 0x402cb1f8 ...>>" "restored_obj #<Foo:0x402cb694>" My created object is destroyed but an other unusable one is alive. The problem seems to be that the alias as BadAlias marked as my block=20 is called and I have no chance this point of view of Syck to change. not even if I put the newly created object to val["point"] back. What can I do? Should I emit direct? For that I have no doc found. I use Yaml in Ruby 1.8.4 on Linux. Arpad Popradi =0A=0A_____________________________________________________________________= ______=0A[origo] Ingatlan apr=F3 =96 =D3ri=E1si lehet=F5s=E9g=0AT=F6bb mint= 120.000 =FAj =E9s haszn=E1lt ingatlan! http://ingatlanbazis.origo.hu=0A=0A |