protected function build_records($result)
    {
        $url = $result['$url'];
        $parent_url = $url;
        if (false !== ($pos = strpos($url, '?'))) {
            $url = substr(0, $pos);
        }

        $url = '/'.trim($url, '/');
        foreach ($result['$data'] as $key => $record) {
            $record_url = $url;
            if (isset($record['id'])) {
                $record_url .= '/'.$record['id'];
            }
            self::$client_links[$record_url] = &self::$client_links[$parent_url];
            $result['$data'][$key] = new Record(array(
                '$url' => $record_url,
                '$data' => $record
            ));
        }

        return $result;
    }