<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_ref(self, ref, attr=None):
 """Set reference to resource Can be used to set references on a resource that is not already created. :param ref: reference to add :type ref: Resource :rtype: Resource """

        ref_attr = '%s_refs' % ref.type.replace('-', '_')
        ref = {
            'to': ref.fq_name,
            'uuid': ref.uuid,
        }
        if ref_attr in self:
            self[ref_attr].append(ref)
        else:
            self[ref_attr] = [ref]
        return self