Class: Sanford::Protocol::BsonBody
- Inherits:
-
Object
- Object
- Sanford::Protocol::BsonBody
- Defined in:
- lib/sanford-protocol.rb
Instance Method Summary collapse
-
#decode(binary) ⇒ Object
BSON returns an ordered hash when deserializing.
-
#encode(data) ⇒ Object
BSON returns a byte buffer when serializing.
Instance Method Details
#decode(binary) ⇒ Object
BSON returns an ordered hash when deserializing. This should be functionally equivalent to a regular hash.
49 |
# File 'lib/sanford-protocol.rb', line 49 def decode(binary); ::BSON.deserialize(binary); end |
#encode(data) ⇒ Object
BSON returns a byte buffer when serializing. This doesn’t always behave like a string, so convert it to one.
45 |
# File 'lib/sanford-protocol.rb', line 45 def encode(data); ::BSON.serialize(data).to_s; end |