Created
June 3, 2014 21:12
-
-
Save durran/bdf0271794366d6a800c to your computer and use it in GitHub Desktop.
BSON Custom Serialization/Deserialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyObject | |
def to_bson(encoded = ''.force_encoding(BINARY)) | |
to_hash.to_bson(encoded) | |
end | |
def self.from_bson(bson) | |
new(Hash.from_bson(bson)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment