class EM::Mongo::Collection

def afind_one(spec_or_object_id=nil, opts={})

def afind_one(spec_or_object_id=nil, opts={})
  spec = case spec_or_object_id
         when nil
           {}
         when BSON::ObjectId
           {:_id => spec_or_object_id}
         when Hash
           spec_or_object_id
         else
           raise TypeError, "spec_or_object_id must be an instance of ObjectId or Hash, or nil"
         end
  afind(spec, opts.merge(:limit => -1)).next_document
end