Class: Moped::BSON::Document

Inherits:
Hash show all
Defined in:
lib/moped/bson/document.rb

Overview

Represents an entire BSON document.

Class Method Summary collapse

Methods included from Extensions::Hash::ClassMethods

#__bson_load__

Methods included from Extensions::Hash

#__bson_dump__

Class Method Details

.deserialize(io, document = new) ⇒ Document

Deserialize the raw bytes into a BSON document object.

Examples:

Deserialize the raw bytes.

Moped::BSON::Document.deserialize("")

Parameters:

  • io (String)

    The raw bytes.

  • document (Document) (defaults to: new)

    The document to load to.

Returns:

  • (Document)

    The document from the raw bytes.

Since:

  • 1.0.0



20
21
22
# File 'lib/moped/bson/document.rb', line 20

def deserialize(io, document = new)
  __bson_load__(io, document)
end

.serialize(document, io = "") ⇒ String

Serialize a document into raw bytes.

Examples:

Serialize the document.

Moped::BSON::Document.serialize(doc, "")

Parameters:

  • document (Document)

    The document to serialize.

  • io (String) (defaults to: "")

    The raw bytes to write to.

Returns:

  • (String)

    The raw serialized bytes.

Since:

  • 1.0.0



35
36
37
# File 'lib/moped/bson/document.rb', line 35

def serialize(document, io = "")
  document.__bson_dump__(io)
end