class BsonUuid

Public Class Methods

from_mongo(value) click to toggle source
# File lib/mm_uses_uuid.rb, line 17
def self.from_mongo(value)
  value
end
to_mongo(value) click to toggle source
# File lib/mm_uses_uuid.rb, line 6
def self.to_mongo(value)
  case value
  when String
    BSON::Binary.new(value.gsub('-', ''), BSON::Binary::SUBTYPE_UUID)
  when BSON::Binary, NilClass
    value
  else
    raise "BsonUuid cannot be of type #{value.class}. String, BSON::Binary and NilClass are the only permitted types"
  end 
end