A
Andrea
I'm using an hash object and i use a Termine Object for the key and, for
now, a String for the value.
The class Termine is this:
class Termine
DEFAULT_LANG = "it"
attr_accessor :descrizione
attr_accessor :lingua
def initialize(descrizione="", lingua=DEFAULT_LANG)
@descrizione = descrizione
@lingua = lingua
end
end
In my test file all is good (compare, edit, delete and reference), but
if I dump all in a file YAML and then I load the file YAML the equal
assertion have a failure.
The attributes 'descrizione' and 'lingua' on the key are the same, but
the problem is that the id of the object is changed... and so there is
the failure.
test_yaml: before hash dump
#<Termine:0x2ada6a8>:Key T4 in lingua it -- Value: Definizione uno
#<Termine:0x2ada720>:Key T3 in lingua it -- Value: Definizione tre
#<Termine:0x2ada750>:Key T2 in lingua it -- Value: Definizione due
#<Termine:0x2ada780>:Key T1 in lingua it -- Value: Definizione uno
test_yaml: after dump (is clear)
test_yaml: after load
#<Termine:0x2ad6400>:Key T4 in lingua it -- Value: Definizione uno
#<Termine:0x2ad5f20>:Key T3 in lingua it -- Value: Definizione tre
#<Termine:0x2ad5a40>:Key T2 in lingua it -- Value: Definizione due
#<Termine:0x2ad5518>:Key T1 in lingua it -- Value: Definizione uno
How can I solve this problem?
Thanks to all for the help...
--Andrea.
now, a String for the value.
The class Termine is this:
class Termine
DEFAULT_LANG = "it"
attr_accessor :descrizione
attr_accessor :lingua
def initialize(descrizione="", lingua=DEFAULT_LANG)
@descrizione = descrizione
@lingua = lingua
end
end
In my test file all is good (compare, edit, delete and reference), but
if I dump all in a file YAML and then I load the file YAML the equal
assertion have a failure.
The attributes 'descrizione' and 'lingua' on the key are the same, but
the problem is that the id of the object is changed... and so there is
the failure.
test_yaml: before hash dump
#<Termine:0x2ada6a8>:Key T4 in lingua it -- Value: Definizione uno
#<Termine:0x2ada720>:Key T3 in lingua it -- Value: Definizione tre
#<Termine:0x2ada750>:Key T2 in lingua it -- Value: Definizione due
#<Termine:0x2ada780>:Key T1 in lingua it -- Value: Definizione uno
test_yaml: after dump (is clear)
test_yaml: after load
#<Termine:0x2ad6400>:Key T4 in lingua it -- Value: Definizione uno
#<Termine:0x2ad5f20>:Key T3 in lingua it -- Value: Definizione tre
#<Termine:0x2ad5a40>:Key T2 in lingua it -- Value: Definizione due
#<Termine:0x2ad5518>:Key T1 in lingua it -- Value: Definizione uno
How can I solve this problem?
Thanks to all for the help...
--Andrea.