Skip to content

Instantly share code, notes, and snippets.

@durran
Created June 3, 2014 21:12
Show Gist options
  • Save durran/bdf0271794366d6a800c to your computer and use it in GitHub Desktop.
Save durran/bdf0271794366d6a800c to your computer and use it in GitHub Desktop.
BSON Custom Serialization/Deserialization
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