Marshaling Objects – Ruby

Ruby can take an object and convert it into stream of bytes that can be stored in database or can exposed outside of application. This is almost similer to Object Serialisation , which is very comman in java. In ruby , same process is called marshaling .

But there are two things need to be considered .

1. Some Objects cannot be dumped , if the objects to be dumped include bindings , procedure or methods objects , instance of class IO, singleton Object , or if you try to dump non-name classes or modules . (It will raise TypeError )

2. When you load marshaled object, Ruby needs to know the defination of class of that object.

very Common use case of Rails using marshaling is to store session data.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s