mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:17 +01:00
added type-erasers for CoreStoreObject property containers
This commit is contained in:
83
Sources/AnyCoreStoreKeyPath.swift
Normal file
83
Sources/AnyCoreStoreKeyPath.swift
Normal file
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// AnyCoreStoreKeyPath.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Created by John Estropia on 2017/10/02.
|
||||
// Copyright © 2017 John Rommel Estropia. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
// MARK: - AnyCoreStoreKeyPath
|
||||
|
||||
public protocol AnyCoreStoreKeyPath {
|
||||
|
||||
var cs_keyPathString: String { get }
|
||||
}
|
||||
|
||||
// SE-0143 is not implemented: https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md
|
||||
//extension KeyPath: AnyCoreStoreKeyPath where Root: NSManagedObject, Value: ImportableAttributeType {
|
||||
//
|
||||
// public var cs_keyPathString: String {
|
||||
//
|
||||
// return self._kvcKeyPathString!
|
||||
// }
|
||||
//}
|
||||
|
||||
extension ValueContainer.Required: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension ValueContainer.Optional: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension TransformableContainer.Required: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension TransformableContainer.Optional: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension RelationshipContainer.ToOne: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension RelationshipContainer.ToManyOrdered: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
extension RelationshipContainer.ToManyUnordered: AnyCoreStoreKeyPath {
|
||||
|
||||
public var cs_keyPathString: String {
|
||||
|
||||
return self.keyPath
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user