This commit is contained in:
John Rommel Estropia
2015-05-04 12:40:16 +09:00
parent b56c08abd9
commit d043d64cb1
41 changed files with 1583 additions and 214 deletions

View File

@@ -20,8 +20,8 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public func commitAndWait() {
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to commit a <\(self.dynamicType)> outside its designated queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a <\(self.dynamicType)> more than once.")
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to commit a \(typeName(self)) outside its designated queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a \(typeName(self)) more than once.")
self.isCommitted = true
self.result = self.context.saveSynchronously()
@@ -35,8 +35,8 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public func beginSynchronous(closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to begin a child transaction from a <\(self.dynamicType)> outside its designated queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to begin a child transaction from an already committed <\(self.dynamicType)>.")
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to begin a child transaction from a \(typeName(self)) outside its designated queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to begin a child transaction from an already committed \(typeName(self)).")
return SynchronousDataTransaction(
mainContext: self.context,
@@ -55,7 +55,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public override func create<T: NSManagedObject>(entity: T.Type) -> T {
HardcoreData.assert(!self.isCommitted, "Attempted to create an entity of type <\(entity)> from an already committed <\(self.dynamicType)>.")
HardcoreData.assert(!self.isCommitted, "Attempted to create an entity of type <\(entity)> from an already committed \(typeName(self)).")
return super.create(entity)
}
@@ -68,7 +68,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public override func fetch<T: NSManagedObject>(object: T) -> T? {
HardcoreData.assert(!self.isCommitted, "Attempted to update an entity of type <\(object.dynamicType)> from an already committed <\(self.dynamicType)>.")
HardcoreData.assert(!self.isCommitted, "Attempted to update an entity of type \(typeName(object)) from an already committed \(typeName(self)).")
return super.fetch(object)
}
@@ -80,7 +80,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public override func delete(object: NSManagedObject) {
HardcoreData.assert(!self.isCommitted, "Attempted to delete an entity of type <\(object.dynamicType)> from an already committed <\(self.dynamicType)>.")
HardcoreData.assert(!self.isCommitted, "Attempted to delete an entity of type \(typeName(object)) from an already committed \(typeName(self)).")
super.delete(object)
}
@@ -90,7 +90,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
*/
public override func rollback() {
HardcoreData.assert(!self.isCommitted, "Attempted to rollback an already committed <\(self.dynamicType)>.")
HardcoreData.assert(!self.isCommitted, "Attempted to rollback an already committed \(typeName(self)).")
super.rollback()
}
@@ -105,7 +105,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
self.closure(transaction: self)
if !self.isCommitted && self.hasChanges {
HardcoreData.log(.Warning, message: "The closure for the <\(self.dynamicType)> completed without being committed. All changes made within the transaction were discarded.")
HardcoreData.log(.Warning, message: "The closure for the \(typeName(self)) completed without being committed. All changes made within the transaction were discarded.")
}
}
return self.result