mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-18 07:24:09 +01:00
remov stateIDs
This commit is contained in:
@@ -116,6 +116,27 @@ open /*abstract*/ class CoreStoreObject: DynamicObject, Hashable {
|
||||
|
||||
internal let rawObject: CoreStoreManagedObject?
|
||||
internal let isMeta: Bool
|
||||
|
||||
internal class func metaProperties(includeSuperclasses: Bool) -> [PropertyProtocol] {
|
||||
|
||||
func keyPaths(_ allKeyPaths: inout [PropertyProtocol], for dynamicType: CoreStoreObject.Type) {
|
||||
|
||||
allKeyPaths.append(contentsOf: dynamicType.meta.propertyProtocolsByName())
|
||||
guard
|
||||
includeSuperclasses,
|
||||
case let superType as CoreStoreObject.Type = (dynamicType as AnyClass).superclass(),
|
||||
superType != CoreStoreObject.self
|
||||
else {
|
||||
|
||||
return
|
||||
}
|
||||
keyPaths(&allKeyPaths, for: superType)
|
||||
}
|
||||
|
||||
var allKeyPaths: [PropertyProtocol] = []
|
||||
keyPaths(&allKeyPaths, for: self)
|
||||
return allKeyPaths
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
@@ -144,6 +165,22 @@ open /*abstract*/ class CoreStoreObject: DynamicObject, Hashable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func propertyProtocolsByName() -> [PropertyProtocol] {
|
||||
|
||||
Internals.assert(self.isMeta, "'propertyProtocolsByName()' accessed from non-meta instance of \(Internals.typeName(self))")
|
||||
|
||||
let cacheKey = ObjectIdentifier(Self.self)
|
||||
if let properties = Static.propertiesCache[cacheKey] {
|
||||
|
||||
return properties
|
||||
}
|
||||
let values: [PropertyProtocol] = Mirror(reflecting: self)
|
||||
.children
|
||||
.compactMap({ $0.value as? PropertyProtocol })
|
||||
Static.propertiesCache[cacheKey] = values
|
||||
return values
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,4 +224,5 @@ fileprivate enum Static {
|
||||
// MARK: FilePrivate
|
||||
|
||||
fileprivate static var metaCache: [ObjectIdentifier: Any] = [:]
|
||||
fileprivate static var propertiesCache: [ObjectIdentifier: [PropertyProtocol]] = [:]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user