Serializing - Deserializing a data structure in RoR

Hi. I have a data structure, with arrays and hashes, with several data
types
inside. For instance:

{
:conditions => [ ‘stand_id = ?’ , 1],
:limit => 10,
:offset => 10
}

I want to serialize this structure in a string, to be stored , then
another
day in other session I would like to restore it exactly as it is, for
instance symbols remain symbols, arrays remain arrays, hashes remain
hashes
and so on for other data types. How can I do that in Ruby / RoR?

Thanks, Vinicius


.----------------------.
| Vinicius Cubas B. |
| viniciuscb gmail.com |
‘----------------------’
http://vinici.us

On 11/1/06, Vinicius Cubas B. [email protected] wrote:

day in other session I would like to restore it exactly as it is, for
instance symbols remain symbols, arrays remain arrays, hashes remain hashes
and so on for other data types. How can I do that in Ruby / RoR?

Let’s say you want to put this in myobject.foo.

myobject.foo = s.to_yaml

Pretty easy.

Now you’ve retrieved myobject from the database and you want to load s
with the stuff that’s serialized in foo.

s = YAML::load(myobject.foo)


_Deirdre http://deirdre.net/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs