def METHOD_NAME(record, pid, serializer, module=None, throws=True,
                     **kwargs):
    """Serialize record according to the passed serializer."""
    if isinstance(record, Record):
        try:
            module = module or 'cernopendata.modules.records.serializers'
            serializer = import_string('.'.join((module, serializer)))
            return serializer.serialize(pid, record, **kwargs)
        except Exception:
            current_app.logger.exception(
                u'Record serialization failed {}.'.format(str(record.id)))
            if throws:
                raise