Skip to content

Commit e580042

Browse files
committed
Remove unmanagedIdAccessor in favor of unmanagedId property in IdentifiedUnmanagedModel
feature/add-unmanagedId-property
1 parent da539b7 commit e580042

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import CoreData
88

99
public protocol IdentifiedUnmanagedModel: ReadableUnmanagedModel {
1010
associatedtype UnmanagedId: Equatable
11-
static var unmanagedIdAccessor: (Self) -> UnmanagedId { get }
11+
var unmanagedId: UnmanagedId { get }
1212
static var managedIdExpression: NSExpression { get }
1313
}
1414

1515
extension IdentifiedUnmanagedModel {
1616
@inlinable
1717
public func readManaged(from context: NSManagedObjectContext) throws -> ManagedModel {
18-
try Self.readManaged(id: Self.unmanagedIdAccessor(self), from: context)
18+
try Self.readManaged(id: unmanagedId, from: context)
1919
}
2020

2121
@inlinable

Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ extension IdentifiableModel_IntId: IdentifiedUnmanagedModel {
100100
}
101101

102102
@inlinable
103-
package static var unmanagedIdAccessor: (IdentifiableModel_IntId) -> Int { \.id }
103+
package var unmanagedId: Int {
104+
id
105+
}
104106
package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_IntId.id)
105107
}
106108

Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ extension IdentifiableModel_UuidId: IdentifiedUnmanagedModel {
100100
}
101101

102102
@inlinable
103-
package static var unmanagedIdAccessor: (IdentifiableModel_UuidId) -> UUID { \.id }
103+
package var unmanagedId: UUID {
104+
id
105+
}
104106
package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_UuidId.id)
105107
}
106108

0 commit comments

Comments
 (0)