# Complete Serialization Options

**URL:** <https://www.ruby-forum.com/t/complete-serialization-options/130773>\
**Category:** Ruby\
**Created:** [March 3, 2008, 8:46am UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773 "2008-03-03T08:46:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsoftware](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@dsoftware](https://www.ruby-forum.com/u/dsoftware)\
**Post date:** [March 3, 2008, 8:46am UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773/1 "2008-03-03T08:46:13Z")

</div>

Is there a way to _completely_ serialize objects and move them to  
another machien in Ruby? I would like to be able to serialize an entire  
object (e.g. all the methods, objects, etc.), then transfer this  
serialized object to another interpreter session, which may or may not  
be on the same machine, and deserialize the object. The objective I  
have in mind is to be able to migrate the object into the other session  
and use it as if it was on the instantiated in that session.

I have read about Marshal and YAML, and these two options don’t seem to  
have that capability. Are these the only two options for serialization  
in Ruby?

---

<div class="post-metadata">

**Author:** ![dsoftware](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@dsoftware](https://www.ruby-forum.com/u/dsoftware)\
**Post date:** [March 3, 2008, 10:53am UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773/2 "2008-03-03T10:53:40Z")

</div>

2008/3/3, Demonic S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> in Ruby?  
> AFAIK yes. Note that there is usually no access to code so you would  
> need to employ some tricks to transfer the code (methods) that is  
> associated with an instance. Note also that you might introduce  
> security risks and other sorts of weird behavior by allowing code to  
> be transferred (just think of different versions of the same class  
> etc.).

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![dsoftware](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@dsoftware](https://www.ruby-forum.com/u/dsoftware)\
**Post date:** [March 3, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773/3 "2008-03-03T15:49:57Z")

</div>

Thanks Robert.

I understand the security issues behind what I am doing. I have some  
follow-up questions to my previous ones.

Is there a centralized structure that holds all the methods, instance  
variables, and then all the ancestor methods, instance variables, etc.  
For  
example, in Python there is self. **dict** , which is basically a hash  
table  
and it holds all the basic structures that make up the object in  
question.  
Now, I know this is not Python, but I was wondering if Ruby had a hash  
table  
or similar object that holds this type of information. Also, is there  
something (e.g. a manual, guide, paper ) that discusses the  
_under-the-hood_  
layout and function of Ruby structures once they are created? I am  
trying  
to understand what I can and can not do with the Ruby Language 🙂 Thanks  
in  
advance.

On Mon, Mar 3, 2008 at 3:52 AM, Robert K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dsoftware](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@dsoftware](https://www.ruby-forum.com/u/dsoftware)\
**Post date:** [March 3, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773/4 "2008-03-03T17:21:02Z")

</div>

I haven’t looked in it yet, but there’s ruby2ruby from  
seattlerb([http://seattlerb.rubyforge.org/](http://seattlerb.rubyforge.org/)). I read on the mailing  
list, but didn’t try it that you can turn full objects to  
sexp-expressions and back to Ruby

---

<div class="post-metadata">

**Author:** ![dsoftware](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@dsoftware](https://www.ruby-forum.com/u/dsoftware)\
**Post date:** [March 3, 2008, 4:43pm UTC](https://www.ruby-forum.com/t/complete-serialization-options/130773/5 "2008-03-03T16:43:43Z")

</div>

2008/3/3, Demonic S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Is there a centralized structure that holds all the methods, instance  
> variables, and then all the ancestor methods, instance variables, etc. For  
> example, in Python there is self. **dict** , which is basically a hash table  
> and it holds all the basic structures that make up the object in question.

You can access methods via #method etc. but you can never access  
method source code in Ruby so I doubt Ruby gives you what you need out  
of the box. But there are projects that will parse Ruby source or give  
you access to the parsed source (IIRC “parse tree” is one of them).

> Now, I know this is not Python, but I was wondering if Ruby had a hash table  
> or similar object that holds this type of information. Also, is there  
> something (e.g. a manual, guide, paper ) that discusses the _under-the-hood_  
> layout and function of Ruby structures once they are created? I am trying  
> to understand what I can and can not do with the Ruby Language 🙂 Thanks in  
> advance.

That’s probably a good question for ruby-core  
[http://www.ruby-lang.org/en/community/mailing-lists/#ruby-core](http://www.ruby-lang.org/en/community/mailing-lists/#ruby-core)

Also, information about how to code an extension will likely help you.  
Sorry, no URL handy here. And then there is of course the source  
code which seems quite readable.

Kind regards

robert
