def rename_collection(db, collection, new_name):
    """
    Renames a MongoDB collection.

    Arguments:

        db (Database): A pymongo ``Database`` object. Can be obtained
            with ``get_db``.

        collection (str): Name of the collection to be renamed.

        new_name (str, func): ``new_name`` can be one of two things::

            1. The new collection name, as a string.
            2. A function which, when passed the current collection name,
                returns the new collection name. If the function
                returns an empty string, the collection will not be
                renamed.
    """
    if hasattr(new_name, '__call__'):
        _new = new_name(collection)
        if _new == '':
            return
    else:
        _new = new_name
    c = db[collection]
    c.rename(_new)
