motion/cdq/object.rb in cdq-0.1.6 vs motion/cdq/object.rb in cdq-0.1.7
- old
+ new
@@ -39,15 +39,22 @@
def save(*args)
contexts.save(*args)
end
+ def find(oid)
+ url = NSURL.URLWithString(oid)
+ object_id = stores.current.managedObjectIDForURIRepresentation(url)
+ contexts.current.existingObjectWithID(object_id, error: nil)
+ end
+
protected
def with_error_object(default, &block)
error = Pointer.new(:object)
result = block.call(error)
if error[0]
+ p error[0].debugDescription
raise "Error while fetching: #{error[0].debugDescription}"
end
result || default
end