WIP: new PartialObject to act as faster KVC wrappers when implementing custom getters and setters for CoreStoreObject

This commit is contained in:
John Rommel Estropia
2017-06-15 08:27:08 +09:00
parent 5689158b43
commit 746d697691
5 changed files with 233 additions and 105 deletions

View File

@@ -135,3 +135,23 @@ open /*abstract*/ class CoreStoreObject: DynamicObject, Hashable {
}
}
}
// MARK: - DynamicObject where Self: CoreStoreObject
public extension DynamicObject where Self: CoreStoreObject {
public func partialObject() -> PartialObject<Self> {
CoreStore.assert(
!self.isMeta,
"Attempted to create a \(cs_typeName(PartialObject<Self>.self)) from a meta object. Meta objects are only used for querying keyPaths and infering types."
)
return PartialObject<Self>(self.rawObject!)
}
internal static var meta: Self {
return self.init(asMeta: ())
}
}