Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Serialization
(section)
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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)