public function writeDocument( array $document )
    {
        fwrite( $this->stream, "--" . $this->boundary . "\r\n" );
        if ( isset( $document['_attachments'] ) )
        {
            $this->writeMultipartDocument( $document );
        }
        else
        {
            $this->writeSimpleDocument( $document );
        }
    }