protected function respondWithModel(Model $model, $functionName = null)
  {
    // Return a partial response
    if ($functionName && isset($this->partialFields))
    {
      // Validate that there are fields set for this method
      if (!isset($this->allowedPartialFields[$functionName]))
      {
        throw new Exception(
          'Partial fields not specified for ' . $functionName
        );
      }

      // Determines if fields is a strict subset of allowed fields
      if (array_diff(
        $this->partialFields,
        $this->allowedPartialFields[$functionName]
      )
      )
      {
        // todo rework exception
        throw new HTTPException(
          "The fields you asked for cannot be returned.",
          401,
          array(
            'dev' => 'You requested to return fields that are not available to be returned in partial responses.',
            'internalCode' => 'P1000',
            'more' => '' // Could have link to documentation here.
          )
        );
      }
      $this->response->data = $model->toArray($this->partialFields);
    }
    // Get the whole record
    else
    {
      $this->response->data = (object)$model->toArray();
      $this->response->getMeta()->count = count($this->response->data);
    }

    // Expand related models
    if ($this->isExpand)
    {
      // todo allow for parsed related fields, model.field
      foreach ($this->expandFields as $modelField)
      {
        //$this->response[$modelField] = $model->getRelated($modelField)->toArray();
      }
    }

    return $this->response;
  }