prev - up - next - index

Marshal

The module for reading and writing Ruby object in a binary format. This format is machine independent. It can dump most of Ruby objects, there are several exceptional objects like IOs. Dumping such objects raises TypeError exception.

module functions:

dump(obj[,port][,limit])

Dumps object recursively. Dumping some kind of instances of the classes like Class, Module, IO, Data, etc. will raises TypeError exception.

portmust be the instance of the IO or its subclass. If port is ommited dump returns the dumped image string.

If the dumping object defines `_dump' method, dump calls that method to dump with the limit argument. It must return the dumped image string. If `_dump' method is provided, the class must provide the reverse method named `_load' as its singleton method, which is called with dumped image string, and should return the retsored object.

The limit argument specified the level of the recursive traverse. the default limit value is 100. In case negative limit value is specified, no limit will checked for dumping.

load(port[, proc])

Creates new object from port, which is either IO or String. If optional second argument proc is specified, the proc will called with every created object as an argument. It can be used, for example, schema evolution.


prev - up - next - index

matz@netlab.co.jp