Small fix and clean

This commit is contained in:
Pfeil, Scott Robert 2020-02-12 21:35:55 -05:00
parent a7c25f0bdf
commit 441fb0c0e1
2 changed files with 3 additions and 14 deletions

View File

@ -18,9 +18,6 @@ public protocol ActionModelProtocol: Model {
var extraParameters: JSONValueDictionary? { get set }
var analyticsData: JSONValueDictionary? { get set }
static var categoryName: String { get }
static var categoryCodingKey: String { get }
// Temporary fix till server changes
var title: String? { get set }
}

View File

@ -33,13 +33,7 @@ public struct ModelRegistry {
/// Registers models for Atomic use.
public static func register<M: Model>(_ type: M.Type) throws {
var category: Category
if let c = categories[M.categoryName] {
category = c
} else {
category = Category(name: M.categoryName, codingKey: M.categoryCodingKey)
}
var category = categories[M.categoryName] ?? Category(name: M.categoryName, codingKey: M.categoryCodingKey)
// Check to ensure the Category/Type combination doesn't exist.
if category.instanceTypes[M.identifier] != nil {
@ -59,11 +53,9 @@ public struct ModelRegistry {
}
private static func getCategory(for typeString: String) -> Category? {
for (_, value) in categories where value.codingKey == typeString {
return value
}
return nil
}