lib/mongomodel/concerns/attributes.rb in mongomodel-0.2.2 vs lib/mongomodel/concerns/attributes.rb in mongomodel-0.2.3

- old
+ new

@@ -54,12 +54,14 @@ docs end module ClassMethods def from_mongo(hash) - doc = class_for_type(hash['_type']).new - doc.attributes.from_mongo!(hash) - doc + if hash + doc = class_for_type(hash['_type']).new + doc.attributes.from_mongo!(hash) + doc + end end private def class_for_type(type) klass = type.constantize