ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PKy¬ ]°aI.'' load-c.rinu„[µü¤U:RDoc::AnyMethod[iI" load:ETI"Marshal::load;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"KReturns the result of converting the serialized data in source into a ;TI"HRuby object (possibly with associated subordinate objects). source ;TI"Cmay be either an instance of IO or an object that responds to ;TI"Yto_str. If proc is specified, each object will be passed to the proc, as the object ;TI"is being deserialized.;To:RDoc::Markup::BlankLineo; ; [I"ONever pass untrusted data (including user supplied input) to this method. ;TI"1Please see the overview for further details.;T: @fileI"marshal.c;T:0@omit_headings_from_table_of_contents_below0I"#load( source [, proc] ) -> obj;T0[I"(p1, p2 = v2);T@FI" Marshal;TcRDoc::NormalModule00PKy¬ ]›_Õ–YYcdesc-Marshal.rinu„[µü¤U:RDoc::NormalModule[iI" Marshal:ET@0o:RDoc::Markup::Document: @parts[o;;[-o:RDoc::Markup::Paragraph;[ I"HThe marshaling library converts collections of Ruby objects into a ;TI"Cbyte stream, allowing them to be stored outside the currently ;TI"Hactive script. This data may subsequently be read and the original ;TI"objects reconstituted.;To:RDoc::Markup::BlankLineo; ;[ I"EMarshaled data has major and minor version numbers stored along ;TI"Ewith the object information. In normal use, marshaling can only ;TI"Gload data written with the same major version number and an equal ;TI"For lower minor version number. If Ruby's ``verbose'' flag is set ;TI"C(normally using -d, -v, -w, or --verbose) the major and minor ;TI"Fnumbers must match exactly. Marshal versioning is independent of ;TI"HRuby's version numbers. You can extract the version by reading the ;TI"'first two bytes of marshaled data.;T@o:RDoc::Markup::Verbatim;[ I"!str = Marshal.dump("thing") ;TI" RUBY_VERSION #=> "1.9.0" ;TI"str[0].ord #=> 4 ;TI"str[1].ord #=> 8 ;T: @format0o; ;[I"HSome objects cannot be dumped: if the objects to be dumped include ;TI"Fbindings, procedure or method objects, instances of class IO, or ;TI"3singleton objects, a TypeError will be raised.;T@o; ;[ I"HIf your class has special serialization needs (for example, if you ;TI"Cwant to serialize in some specific format), or if it contains ;TI"Iobjects that would otherwise not be serializable, you can implement ;TI"%your own serialization strategy.;T@o; ;[ I"HThere are two methods of doing this, your object can define either ;TI"Omarshal_dump and marshal_load or _dump and _load. marshal_dump will take ;TI"Lprecedence over _dump if both are defined. marshal_dump may result in ;TI"smaller Marshal strings.;T@S:RDoc::Markup::Heading: leveli: textI"Security considerations;T@o; ;[I"NBy design, Marshal.load can deserialize almost any class loaded into the ;TI"ORuby process. In many cases this can lead to remote code execution if the ;TI"5Marshal data is loaded from an untrusted source.;T@o; ;[I"RAs a result, Marshal.load is not suitable as a general purpose serialization ;TI"Rformat and you should never unmarshal user supplied input or other untrusted ;TI" data.;T@o; ;[ I"RIf you need to deserialize untrusted data, use JSON or another serialization ;TI"Pformat that is only able to load simple, 'primitive' types such as String, ;TI"LArray, Hash, etc. Never allow user input to specify arbitrary types to ;TI"deserialize into.;T@S; ;i;I""marshal_dump and marshal_load;T@o; ;[I"DWhen dumping an object the method marshal_dump will be called. ;TI"Pmarshal_dump must return a result containing the information necessary for ;TI"Lmarshal_load to reconstitute the object. The result can be any object.;T@o; ;[I"JWhen loading an object dumped using marshal_dump the object is first ;TI"Nallocated then marshal_load is called with the result from marshal_dump. ;TI"Nmarshal_load must recreate the object from the information in the result.;T@o; ;[I" Example:;T@o; ;[I"class MyObj ;TI"* def initialize name, version, data ;TI" @name = name ;TI" @version = version ;TI" @data = data ;TI" end ;TI" ;TI" def marshal_dump ;TI" [@name, @version] ;TI" end ;TI" ;TI" def marshal_load array ;TI"! @name, @version = array ;TI" end ;TI" end ;T; 0S; ;i;I"_dump and _load;T@o; ;[I"OUse _dump and _load when you need to allocate the object you're restoring ;TI"yourself.;T@o; ;[ I"PWhen dumping an object the instance method _dump is called with an Integer ;TI"Qwhich indicates the maximum depth of objects to dump (a value of -1 implies ;TI"Jthat you should disable depth checking). _dump must return a String ;TI"Econtaining the information necessary to reconstitute the object.;T@o; ;[I"PThe class method _load should take a String and use it to return an object ;TI"of the same class.;T@o; ;[I" Example:;T@o; ;[I"class MyObj ;TI"* def initialize name, version, data ;TI" @name = name ;TI" @version = version ;TI" @data = data ;TI" end ;TI" ;TI" def _dump level ;TI"$ [@name, @version].join ':' ;TI" end ;TI" ;TI" def self._load args ;TI" new(*args.split(':')) ;TI" end ;TI" end ;T; 0o; ;[I"MSince Marhsal.dump outputs a string you can have _dump return a Marshal ;TI"Astring which is Marshal.loaded in _load for complex objects.;T: @fileI"marshal.c;T:0@omit_headings_from_table_of_contents_below0;0;0[[U:RDoc::Constant[iI"MAJOR_VERSION;TI"Marshal::MAJOR_VERSION;T00o;;[o; ;[I"major version;T@;@‰;0@‰@cRDoc::NormalModule0U;[iI"MINOR_VERSION;TI"Marshal::MINOR_VERSION;T00o;;[o; ;[I"minor version;T@;@‰;0@‰@@•0[[[I" class;T[[: public[[I" dump;TI"marshal.c;T[I" load;T@¨[I" restore;T@¨[:protected[[: private[[I" instance;T[[;[[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@‰@‰cRDoc::TopLevelPKy¬ ]¿¾Súú dump-c.rinu„[µü¤U:RDoc::AnyMethod[iI" dump:ETI"Marshal::dump;TT: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I";Serializes obj and all descendant objects. If anIO is ;TI"Ispecified, the serialized data will be written to it, otherwise the ;TI"Cdata will be returned as a String. If limit is specified, the ;TI"Htraversal of subobjects will be limited to that depth. If limit is ;TI"6negative, no checking of depth will be performed.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"class Klass ;TI" def initialize(str) ;TI" @str = str ;TI" end ;TI" def say_hello ;TI" @str ;TI" end ;TI" end ;T: @format0o; ; [I"(produces no output);T@o; ; [ I"o = Klass.new("hello\n") ;TI"data = Marshal.dump(o) ;TI"obj = Marshal.load(data) ;TI""obj.say_hello #=> "hello\n" ;T; 0o; ; [I"*Marshal can't dump following objects:;To:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [I"anonymous Class/Module.;To;;0; [o; ; [I"Pobjects which are related to system (ex: Dir, File::Stat, IO, File, Socket ;TI"and so on);To;;0; [o; ; [I"Jan instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ;TI"ThreadGroup, Continuation;To;;0; [o; ; [I"+objects which define singleton methods;T: @fileI"marshal.c;T:0@omit_headings_from_table_of_contents_below0I"-dump( obj [, anIO] , limit=-1 ) -> anIO ;T0[I"(p1, p2 = v2, p3 = v3);T@AFI" Marshal;TcRDoc::NormalModule00PKy¬ ]m'»å00 restore-c.rinu„[µü¤U:RDoc::AnyMethod[iI" restore:ETI"Marshal::restore;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"KReturns the result of converting the serialized data in source into a ;TI"HRuby object (possibly with associated subordinate objects). source ;TI"Cmay be either an instance of IO or an object that responds to ;TI"Yto_str. If proc is specified, each object will be passed to the proc, as the object ;TI"is being deserialized.;To:RDoc::Markup::BlankLineo; ; [I"ONever pass untrusted data (including user supplied input) to this method. ;TI"1Please see the overview for further details.;T: @fileI"marshal.c;T:0@omit_headings_from_table_of_contents_below0I"&restore( source [, proc] ) -> obj;T0[I"(p1, p2 = v2);T@FI" Marshal;TcRDoc::NormalModule00PKy¬ ]°aI.'' load-c.rinu„[µü¤PKy¬ ]›_Õ–YY`cdesc-Marshal.rinu„[µü¤PKy¬ ]¿¾Súú ùdump-c.rinu„[µü¤PKy¬ ]m'»å00 ,restore-c.rinu„[µü¤PK.˜!