WIP: documentation

This commit is contained in:
John Estropia
2017-05-09 21:16:03 +09:00
parent 48828fdca3
commit 19abedfa9f
10 changed files with 197 additions and 55 deletions

View File

@@ -31,6 +31,27 @@ import Foundation
open class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
public let sourceVersion: ModelVersion
public let destinationVersion: ModelVersion
public required init(from sourceVersion: ModelVersion, to destinationVersion: ModelVersion, entityMappings: Set<CustomMapping> = []) {
CoreStore.assert(
cs_lazy {
let sources = entityMappings.flatMap({ $0.entityMappingSourceEntity })
let destinations = entityMappings.flatMap({ $0.entityMappingDestinationEntity })
return sources.count == Set(sources).count
&& destinations.count == Set(destinations).count
},
"Duplicate source/destination entities found in provided \"entityMappings\" argument."
)
self.sourceVersion = sourceVersion
self.destinationVersion = destinationVersion
self.entityMappings = entityMappings
}
// MARK: - CustomMapping
public enum CustomMapping: Hashable {
@@ -40,7 +61,7 @@ open class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
case deleteEntity(sourceEntity: EntityName)
case insertEntity(destinationEntity: EntityName)
case copyEntity(sourceEntity: EntityName, destinationEntity: EntityName)
case transformEntity(sourceEntity: EntityName, destinationEntity: EntityName, transformEntity: Transformer)
case transformEntity(sourceEntity: EntityName, destinationEntity: EntityName, transformer: Transformer)
static func inferredTransformation(_ sourceObject: UnsafeSourceObject, _ createDestinationObject: () -> UnsafeDestinationObject) throws -> Void {
@@ -211,29 +232,6 @@ open class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
}
// MARK: - Public
public let sourceVersion: ModelVersion
public let destinationVersion: ModelVersion
public required init(from sourceVersion: ModelVersion, to destinationVersion: ModelVersion, entityMappings: Set<CustomMapping> = []) {
CoreStore.assert(
cs_lazy {
let sources = entityMappings.flatMap({ $0.entityMappingSourceEntity })
let destinations = entityMappings.flatMap({ $0.entityMappingDestinationEntity })
return sources.count == Set(sources).count
&& destinations.count == Set(destinations).count
},
"Duplicate source/destination entities found in provided \"entityMappings\" argument."
)
self.sourceVersion = sourceVersion
self.destinationVersion = destinationVersion
self.entityMappings = entityMappings
}
// MARK: Equatable
public static func == (lhs: CustomSchemaMappingProvider, rhs: CustomSchemaMappingProvider) -> Bool {
@@ -607,7 +605,7 @@ open class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
.transformEntity(
sourceEntity: sourceEntityName,
destinationEntity: destinationEntityName,
transformEntity: CustomMapping.inferredTransformation
transformer: CustomMapping.inferredTransformation
)
)
}