protected function _createResource(ModelEntityInterface $entity, array $config = array())
    {
        $config = array_merge(array(
            'links'         => true,
            'relationships' => true
        ), $config);

        $data = array(
            'type' => $this->_callCustomMethod($entity, 'type') ?: StringInflector::pluralize($entity->getIdentifier()->name),
            'id'   => $this->_callCustomMethod($entity, 'id') ?: $entity->{$entity->getIdentityKey()},
            'attributes' => $this->_callCustomMethod($entity, 'attributes') ?: $entity->toArray()
        );

        if (isset($this->_fields[$data['type']]))
        {
            $fields = array_flip($this->_fields[$data['type']]);
            $data['attributes'] = array_intersect_key($data['attributes'], $fields);
        }

        if ($config['links'])
        {
            $links = $this->_callCustomMethod($entity, 'links') ?: array('self' => (string)$this->_getEntityRoute($entity));
            if ($links) {
                $data['links'] = $links;
            }
        }

        if ($config['relationships'])
        {
            $relationships = $this->_callCustomMethod($entity, 'relationships');
            if ($relationships) {
                $data['relationships'] = $relationships;
            }
        }

        return $data;
    }