provide direct conversion from DynamicObject to ObjectSnapshot

This commit is contained in:
John Estropia
2019-10-28 12:03:17 +09:00
parent 717cb75720
commit 88ab0b5e15

View File

@@ -75,6 +75,19 @@ extension CoreStoreObject: ObjectRepresentation {}
extension DynamicObject where Self: ObjectRepresentation {
// MARK: Public
/**
A thread-safe `struct` that is a full-copy of the object's properties
*/
public func asSnapshot() -> ObjectSnapshot<Self>? {
return self.cs_toRaw()
.managedObjectContext
.flatMap({ ObjectSnapshot<Self>(objectID: self.cs_id(), context: $0) })
}
// MARK: ObjectRepresentation
public func objectID() -> Self.ObjectID {