lib/collector/repository.rb in collector-0.0.16 vs lib/collector/repository.rb in collector-0.0.17
- old
+ new
@@ -33,21 +33,21 @@
collection.insert(attributes)
end
def serialize!(model)
attributes = serialize(model)
- attributes["_id"] = attributes.delete("id")
+ attributes["_id"] = BSON::ObjectId.from_string(attributes.delete("id")) if attributes["id"]
attributes.reject! { |key, val| val.nil? }
attributes
end
def serialize(model)
model.attributes.with_indifferent_access
end
def deserialize!(attributes)
attributes = attributes.with_indifferent_access
- attributes["id"] = attributes.delete("_id")
+ attributes["id"] = attributes.delete("_id").to_s
deserialize(attributes)
end
def deserialize(attributes)
model.new(attributes)