mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-23 09:51:30 +01:00
Support typed errors. Misc formatting
This commit is contained in:
@@ -116,8 +116,19 @@ extension FieldContainer {
|
||||
_ keyPath: KeyPathString,
|
||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||
customGetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>
|
||||
) -> V
|
||||
)? = nil,
|
||||
customSetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>,
|
||||
_ newValue: V
|
||||
) -> Void
|
||||
)? = nil,
|
||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
||||
) {
|
||||
|
||||
@@ -157,8 +168,19 @@ extension FieldContainer {
|
||||
_ keyPath: KeyPathString,
|
||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||
customGetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>
|
||||
) -> V
|
||||
)? = nil,
|
||||
customSetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>,
|
||||
_ newValue: V
|
||||
) -> Void
|
||||
)? = nil,
|
||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = [],
|
||||
dynamicInitialValue: @escaping () -> V
|
||||
) {
|
||||
@@ -255,7 +277,10 @@ extension FieldContainer {
|
||||
return ObjectType.self
|
||||
}
|
||||
|
||||
internal static func read(field: FieldProtocol, for rawObject: CoreStoreManagedObject) -> Any? {
|
||||
internal static func read(
|
||||
field: FieldProtocol,
|
||||
for rawObject: CoreStoreManagedObject
|
||||
) -> Any? {
|
||||
|
||||
let field = field as! Self
|
||||
if let customGetter = field.customGetter {
|
||||
@@ -276,7 +301,10 @@ extension FieldContainer {
|
||||
}
|
||||
}
|
||||
|
||||
internal static func modify(field: FieldProtocol, for rawObject: CoreStoreManagedObject, newValue: Any?) {
|
||||
internal static func modify(
|
||||
field: FieldProtocol,
|
||||
for rawObject: CoreStoreManagedObject, newValue: Any?
|
||||
) {
|
||||
|
||||
Internals.assert(
|
||||
rawObject.isEditableInContext() == true,
|
||||
@@ -379,7 +407,8 @@ extension FieldContainer {
|
||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)?,
|
||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)?,
|
||||
dynamicInitialValue: (() -> V)?,
|
||||
affectedByKeyPaths: @escaping () -> Set<KeyPathString>) {
|
||||
affectedByKeyPaths: @escaping () -> Set<KeyPathString>
|
||||
) {
|
||||
|
||||
self.keyPath = keyPath
|
||||
self.entityDescriptionValues = {
|
||||
@@ -403,8 +432,19 @@ extension FieldContainer {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private let customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)?
|
||||
private let customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)?
|
||||
private let customGetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>
|
||||
) -> V
|
||||
)?
|
||||
private let customSetter: (
|
||||
(
|
||||
_ object: ObjectProxy<O>,
|
||||
_ field: ObjectProxy<O>.FieldProxy<V>,
|
||||
_ newValue: V
|
||||
) -> Void
|
||||
)?
|
||||
private let dynamicInitialValue: (() -> V)?
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user