Module: Mongo::DBRef::ClassMethods

Defined in:
lib/mongo/dbref.rb

Overview

Since:

  • 2.1.0

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer) ⇒ Hash, DBRef

Deserialize the hash from BSON, converting to a DBRef if appropriate.

Parameters:

  • buffer (String)

    The bson representing a hash.

Returns:

  • (Hash, DBRef)

    The decoded hash or DBRef.

See Also:

Since:

  • 2.0.0



103
104
105
106
107
108
109
# File 'lib/mongo/dbref.rb', line 103

def from_bson(buffer)
  decoded = super
  if ref = decoded[COLLECTION]
    decoded = DBRef.new(ref, decoded[ID], decoded[DATABASE])
  end
  decoded
end