Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Serialization
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Ruby=== [[Ruby programming language|Ruby]] includes the standard module <code>[https://docs.ruby-lang.org/en/master/Marshal.html Marshal]</code> with 2 methods <code>dump</code> and <code>load</code>, akin to the standard Unix utilities <code>[[dump (Unix)|dump]]</code> and <code>[[restore (program)|restore]]</code>. These methods serialize to the standard class <code>String</code>, that is, they effectively become a sequence of bytes. Some objects cannot be serialized (doing so would raise a <code>TypeError</code> exception): bindings, procedure objects, instances of class IO, singleton objects and interfaces. If a class requires custom serialization (for example, it requires certain cleanup actions done on dumping / restoring), it can be done by implementing 2 methods: <code>_dump</code> and <code>_load</code>. The [[instance method]] <code>_dump</code> should return a <code>String</code> object containing all the information necessary to reconstitute objects of this class and all referenced objects up to a maximum depth given as an integer parameter (a value of -1 implies that depth checking should be disabled). The [[class method]] <code>_load</code> should take a <code>String</code> and return an object of this class.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Serialization
(section)
Add topic