I am using the xkeyval package to set a key "name". This value is then used in the hyperref package. Please see the sample code below:
File: mysuperclass.cls
\ProvidesClass{mysuperclass}
\LoadClass{article}
\RequirePackage{xkeyval}%
\def\docauthorname{A. U. Thor}%
\def\docname{\jobname.tex}%
\def\docdate{\today}%
\define@key{mysuperclass.cls}{docdate}[\today]{%
\def\docdate{#1}%
}
\define@key{mysuperclass.cls}{author}[A. U. Thor]{%
\def\docauthorname{#1}%
}
\define@key{mysuperclass.cls}{docname}[]{%
\def\docname{#1}%
}
\ExecuteOptionsX{author,docdate}
\ProcessOptionsX%
\RequirePackage{fancyhdr}
\AtBeginDocument{%
\lhead[\docauthorname]{{\docauthorname}}%
\chead[\docdate]{\docdate}%
\rhead[]{\docname}%
\pagestyle{fancy}%
}
\RequirePackage{hyperref}
\hypersetup{%
pdfauthor={{\docauthorname}}%
}%
\endinput
File: main.tex
\documentclass[docdate=1/1/2016,author=My Full Name with Spaces,docname=yelostfile]{mysuperclass}
\usepackage{blindtext}
\begin{document}
\blindtext[2]
\end{document}
Please note that the above code is taken from here. Below is a screenshot of the generated PDF:

Please see below the PDF properties, pay attention to the author name:

I found a similar question here and followed it. Unfortunately, it doesn't seem working as expected.
My question is how to retain whitespaces in xkeyval?
Workaround
The actual answer given by @Skillmon which requires TexLive 2021-06-01 and uses the expkv-opt package. @Skillmon, kindly suggested a workaround to avoid such dependencies. I am posting the complete code below for reference:
\begin{filecontents}{mysuperclass.cls}
\ProvidesClass{mysuperclass}
\LoadClass{article}
\RequirePackage{xkeyval}
\RequirePackage{etoolbox}
\RequirePackage{hyperref}
\RequirePackage{fancyhdr}
\define@key{mysuperclass.cls}{docdate}[\today]{
\def\docdate{#1}
}
\define@key{mysuperclass.cls}{author}[A. U. Thor]{
\def\docauthorname{#1}
}
\define@key{mysuperclass.cls}{docname}[My Document]{
\def\docname{#1}
}
\ExecuteOptionsX{author,docdate,docname}
\ProcessOptionsX
\newcommand\setauthor[1]{
\setkeys{mysuperclass.cls}{author=#1}
}
\newcommand\setdocdate[1]{
\setkeys{mysuperclass.cls}{docdate=#1}
}
\newcommand\setdocname[1]{
\setkeys{mysuperclass.cls}{docname=#1}
}
\AtEndPreamble{
\hypersetup{
pdfauthor={{\docauthorname}}
}
\AtBeginDocument{
\lhead[\docauthorname]{{\docauthorname}}
\chead[\docdate]{\docdate}
\rhead[]{\docname}
\pagestyle{fancy}
}
}
\endinput
\end{filecontents}
\documentclass{mysuperclass}
\setauthor{My Full Name with Spaces}
\setdocdate{1/1/2016}
\setdocname{yelostfile}
\usepackage{blindtext}
\begin{document}
\blindtext[2]
\end{document}
