         # File lib/ferret/index.rb, line 626
    626:     def batch_update(docs)
    627:       @dir.synchronize do
    628:         ids = values = nil
    629:         case docs
    630:         when Array
    631:           ids = docs.collect{|doc| doc[@id_field].to_s}
    632:           if ids.include?(nil)
    633:             raise ArgumentError, "all documents must have an #{@id_field} "
    634:                                  "field when doing a batch update"
    635:           end
    636:         when Hash
    637:           ids = docs.keys
    638:           docs = docs.values
    639:         else
    640:           raise ArgumentError, "must pass Hash or Array, not #{docs.class}"
    641:         end
    642:         batch_delete(ids)
    643:         ensure_writer_open()
    644:         docs.each {|new_doc| @writer << new_doc }
    645:         flush()
    646:       end
    647:     end