def add_resource(type, rsrc, name = nil)
            if name.nil?
                rsrc_name = self.resources(type).key(rsrc)
                return rsrc_name if rsrc_name
            end

            name ||= new_id(type)
            target = self.is_a?(Resources) ? self : (self.Resources ||= Resources.new)

            rsrc_dict = (target[type] and target[type].solve) || (target[type] = Dictionary.new)
            rsrc_dict[name.to_sym] = rsrc

            name
        end
def add_resource(type, rsrc, name = nil)
            if name.nil?
                rsrc_name = self.resources(type).key(rsrc)
                return rsrc_name if rsrc_name
            end

            name ||= new_id(type)
            target = self.is_a?(Resources) ? self : (self.Resources ||= Resources.new)

            rsrc_dict = (target[type] and target[type].solve) || (target[type] = Dictionary.new)
            rsrc_dict[name.to_sym] = rsrc

            name
        end
Adds a resource of the specified _type_ in the current object.
 If _name_ is not specified, a new name will be automatically generated.