public function set(array $data)
    {
        $result = null;
        $this->hook->attach('rating.set.before', $data, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $conditions = array(
            'user_id' => $data['user_id'],
            'product_id' => $data['product_id']
        );

        $this->db->delete('rating_user', $conditions);

        $this->addByUser($data);

        $result = $this->setBayesian($data);
        $this->hook->attach('rating.set.after', $data, $result, $this);
        return $result;
    }