Quote environment with reference at the end right

There's a nice \signed macro that serves this purpose on page 106 of the TeXbook; here's a little variation used to build the aquote environment which behaves as expected;

\documentclass{book}

\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil(#1)%
  \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newsavebox\mybox
\newenvironment{aquote}[1]
  {\savebox\mybox{#1}\begin{quote}}
  {\signed{\usebox\mybox}\end{quote}}

\begin{document}

\begin{aquote}{Bourbaki}
This is a case where the name fits in nicely with the quote so the name will appear in the same line.
\end{aquote}

\begin{aquote}{Nicolas Bourbaki}
This is a case where the name won't fit in nicely with the quote, and in this case the name will be moved to the next line.
\end{aquote}

\end{document}

Here's the result:

enter image description here


Also for completeness, please refer to the attrib package. You can approximate the effect you want with the following:

\begin{quote}
  We call a disposition the arrangement of that which has parts, in respect 
  either of place or of capacity or of kind; for there must be a certain 
  position, as the word ‘disposition’ shows.

  \attrib{{\em Metaphysics} {\greektext D}.19, 1022b1--3}
\end{quote}

I just want to add for completeness that the memoir package provides the

\sourceatright[⟨length⟩]{⟨text⟩}

command, which can be used immediately after a quote or quotation environment and does what the question asks.