class Xcodeproj::Project::Object::Association::HasOne
@todo Does this need ‘new object’-callback support too?
def direct_get
def direct_get @owner.project.objects[@owner.send(@reflection.attribute_getter)] end
def direct_set(object)
def direct_set(object) @owner.send(@reflection.attribute_setter, object.uuid) end
def inverse_get
def inverse_get # Loop over all objects of the class and find the one that includes # this object in the specified uuid list. @owner.project.objects.list_by_class(@reflection.klass).find do |object| object.send(@reflection.inverse.attribute_getter).include?(@owner.uuid) end end
def inverse_set(object)
def inverse_set(object) # Remove this object from the uuid list of the target # that this object was associated to. if previous = @owner.send(@reflection.name) previous.send(@reflection.inverse.attribute_getter).delete(@owner.uuid) end # Now assign this object to the new object object.send(@reflection.inverse.attribute_getter) << @owner.uuid if object end