protected function fromResponse( phpillowResponse $response )
    {
        // Set all document property values from response, if available in the
        // response.
        //
        // Also fill a revision object with the set attributes, so that the
        // current revision is also available in history, and it is stored,
        // when the object is modified and stored again.
        $revision = new StdClass();
        $revision->_date = time();
        foreach ( $this->properties as $property => $v )
        {
            if ( isset( $response->$property ) )
            {
                $this->storage->$property = $response->$property;
                $revision->$property = $response->$property;
            }
        }

        // Set special properties from response object
        $this->storage->_rev = $response->_rev;
        $this->storage->_id  = $response->_id;

        // Set attachments array, if the response object contains attachments.
        if ( isset( $response->_attachments ) )
        {
            $this->storage->_attachments = $response->_attachments;
        }

        // Check if the source document already contains a revision history and
        // store it in this case in the document object, if the object should
        // be versioned at all.
        if ( $this->versioned )
        {
            if ( isset( $response->revisions ) )
            {
                $this->storage->revisions = $response->revisions;
            }

            // Add current revision to revision history
            $this->storage->revisions[] = (array) $revision;
        }

        // Document freshly loaded, so it is not modified, and not a new
        // document...
        $this->modified = false;
        $this->newDocument = false;
    }