indentation
This commit is contained in:
parent
ea6089e772
commit
a7c25f0bdf
@ -34,7 +34,7 @@ public struct ModelRegistry {
|
|||||||
public static func register<M: Model>(_ type: M.Type) throws {
|
public static func register<M: Model>(_ type: M.Type) throws {
|
||||||
|
|
||||||
var category: Category
|
var category: Category
|
||||||
|
|
||||||
if let c = categories[M.categoryName] {
|
if let c = categories[M.categoryName] {
|
||||||
category = c
|
category = c
|
||||||
} else {
|
} else {
|
||||||
@ -58,8 +58,6 @@ public struct ModelRegistry {
|
|||||||
return getCategory(for: type)?.instanceTypes[name]
|
return getCategory(for: type)?.instanceTypes[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static func getCategory(for typeString: String) -> Category? {
|
private static func getCategory(for typeString: String) -> Category? {
|
||||||
|
|
||||||
for (_, value) in categories where value.codingKey == typeString {
|
for (_, value) in categories where value.codingKey == typeString {
|
||||||
@ -73,8 +71,6 @@ public struct ModelRegistry {
|
|||||||
return getCategory(for: typeString)?.instanceTypes[name]
|
return getCategory(for: typeString)?.instanceTypes[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static func getCodingKey<T>(for type: T.Type) throws -> AnyCodingKey{
|
public static func getCodingKey<T>(for type: T.Type) throws -> AnyCodingKey{
|
||||||
guard let category = getCategory(for: type) else {
|
guard let category = getCategory(for: type) else {
|
||||||
throw ModelRegistry.Error.decoderOther(message: "decodeModelsIfPresent only works for objects implementing the Model protocol")
|
throw ModelRegistry.Error.decoderOther(message: "decodeModelsIfPresent only works for objects implementing the Model protocol")
|
||||||
@ -200,7 +196,7 @@ public extension KeyedEncodingContainer where Key: CodingKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for encoding the container into a list of lists of Models. needs instance type as input paramaeter list
|
/// Convenience function for encoding the container into a list of lists of Models. needs instance type as input paramaeter list
|
||||||
mutating func encodeModels2D(_ list: [[Model]]?, forKey key:KeyedEncodingContainer<K>.Key) throws {
|
mutating func encodeModels2D(_ list: [[Model]]?, forKey key:KeyedEncodingContainer<K>.Key) throws {
|
||||||
|
|
||||||
guard let list = list else { return }
|
guard let list = list else { return }
|
||||||
var unkeyedContainer = nestedUnkeyedContainer(forKey: key)
|
var unkeyedContainer = nestedUnkeyedContainer(forKey: key)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user