Results for: "Array.new"

No documentation available

The marshaling library converts collections of Ruby objects into a byte stream, allowing them to be stored outside the currently active script. This data may subsequently be read and the original objects reconstituted.

Marshaled data has major and minor version numbers stored along with the object information. In normal use, marshaling can only load data written with the same major version number and an equal or lower minor version number. If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or –verbose) the major and minor numbers must match exactly. Marshal versioning is independent of Ruby’s version numbers. You can extract the version by reading the first two bytes of marshaled data.

str = Marshal.dump("thing")
RUBY_VERSION   #=> "1.9.0"
str[0].ord     #=> 4
str[1].ord     #=> 8

Some objects cannot be dumped: if the objects to be dumped include bindings, procedure or method objects, instances of class IO, or singleton objects, a TypeError will be raised.

If your class has special serialization needs (for example, if you want to serialize in some specific format), or if it contains objects that would otherwise not be serializable, you can implement your own serialization strategy.

There are two methods of doing this, your object can define either marshal_dump and marshal_load or _dump and _load. marshal_dump will take precedence over _dump if both are defined. marshal_dump may result in smaller Marshal strings.

Security considerations

By design, Marshal.load can deserialize almost any class loaded into the Ruby process. In many cases this can lead to remote code execution if the Marshal data is loaded from an untrusted source.

As a result, Marshal.load is not suitable as a general purpose serialization format and you should never unmarshal user supplied input or other untrusted data.

If you need to deserialize untrusted data, use JSON or another serialization format that is only able to load simple, ‘primitive’ types such as String, Array, Hash, etc. Never allow user input to specify arbitrary types to deserialize into.

marshal_dump and marshal_load

When dumping an object the method marshal_dump will be called. marshal_dump must return a result containing the information necessary for marshal_load to reconstitute the object. The result can be any object.

When loading an object dumped using marshal_dump the object is first allocated then marshal_load is called with the result from marshal_dump. marshal_load must recreate the object from the information in the result.

Example:

class MyObj
  def initialize name, version, data
    @name    = name
    @version = version
    @data    = data
  end

  def marshal_dump
    [@name, @version]
  end

  def marshal_load array
    @name, @version = array
  end
end

_dump and _load

Use _dump and _load when you need to allocate the object you’re restoring yourself.

When dumping an object the instance method _dump is called with an Integer which indicates the maximum depth of objects to dump (a value of -1 implies that you should disable depth checking). _dump must return a String containing the information necessary to reconstitute the object.

The class method _load should take a String and use it to return an object of the same class.

Example:

class MyObj
  def initialize name, version, data
    @name    = name
    @version = version
    @data    = data
  end

  def _dump level
    [@name, @version].join ':'
  end

  def self._load args
    new(*args.split(':'))
  end
end

Since Marshal.dump outputs a string you can have _dump return a Marshal string which is Marshal.loaded in _load for complex objects.

No documentation available
No documentation available

Generator

Cleared reference exception

The base exception for JSON errors.

This exception is raised if a parser error occurs.

This exception is raised if the nesting of parsed data structures is too deep.

Generic Error for all of OpenSSL::BN (big num)

Scan scalars for built in types

Socket::ResolutionError is the error class for hostname resolution.

WIN32OLE::Param objects represent param information of the OLE method.

Subclass of Zlib::Error

When zlib returns a Z_VERSION_ERROR, usually if the zlib library version is incompatible with the version assumed by the caller.

Response class for Found responses (status code 302).

The Found response indicates that the client should look at (browse to) another URL.

References:

Response class for Temporary Redirect responses (status code 307).

The request should be repeated with another URI; however, future requests should still use the original URI.

References:

Response class for Payload Too Large responses (status code 413).

The request is larger than the server is willing or able to process.

References:

Response class for Bad Gateway responses (status code 502).

The server was acting as a gateway or proxy and received an invalid response from the upstream server.

References:

Response class for Gateway Timeout responses (status code 504).

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

References:

Response class for Gateway Timeout responses (status code 504).

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

References:

Response class for Variant Also Negotiates responses (status code 506).

Transparent content negotiation for the request results in a circular reference.

References:

No documentation available

Base class of exceptions from OptionParser.

Raises when there is an argument for a switch which takes no argument.

Represents assigning to a class variable using an operator that isn’t ‘=`.

@@target += value
^^^^^^^^^^^^^^^^^
Search took: 4ms  ·  Total Results: 3535