CustomMapping
public enum CustomMapping : Hashable
Provides the type of mapping for an entity. Mappings of entities with no CustomMapping
provided will be automatically calculated if possible. Any conflicts or ambiguity will raise an assertion.
-
The
sourceEntity
is meant to be removed from the sourceDynamicSchema
and should not be migrated to the destinationDynamicSchema
.Declaration
Swift
case deleteEntity(sourceEntity: EntityName)
-
The
destinationEntity
is newly added to the destinationDynamicSchema
and has no mapping from the sourceDynamicSchema
.Declaration
Swift
case insertEntity(destinationEntity: EntityName)
-
The
DynamicSchema
s entity has no changes and can be copied directly fromsourceEntity
todestinationEntity
.Declaration
Swift
case copyEntity(sourceEntity: EntityName, destinationEntity: EntityName)
-
The
DynamicSchema
s entity needs transformations fromsourceEntity
todestinationEntity
. Thetransformer
closure will be used to apply the changes. TheCustomMapping.inferredTransformation
method can be used directly as thetransformer
if the changes can be inferred (i.e. lightweight).Declaration
Swift
case transformEntity(sourceEntity: EntityName, destinationEntity: EntityName, transformer: Transformer)
-
The closure type for
CustomMapping.transformEntity
.Declaration
Swift
public typealias Transformer = (_ sourceObject: UnsafeSourceObject, _ createDestinationObject: () -> UnsafeDestinationObject) throws -> Void
Parameters
sourceObject
a proxy object representing the source entity. The properties can be accessed via keyPath.
createDestinationObject
the closure to create the object for the destination entity. The
CustomMapping.inferredTransformation
method can be used directly as thetransformer
if the changes can be inferred (i.e. lightweight). The object is created lazily and executing the closure multiple times will return the same instance. The destination object’s properties can be accessed and updated via keyPath. -
The
CustomMapping.inferredTransformation
method can be used directly as thetransformer
if the changes can be inferred (i.e. lightweight).Declaration
Swift
public static func inferredTransformation(_ sourceObject: UnsafeSourceObject, _ createDestinationObject: () -> UnsafeDestinationObject) throws
-
Declaration
Swift
public static func == (lhs: CustomMapping, rhs: CustomMapping) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)