Merge branch 'feature/coding' into feature/model_wip_kamlesh

This commit is contained in:
Suresh, Kamlesh 2019-12-12 17:33:03 -05:00
commit d0196e6e58
2 changed files with 12 additions and 1 deletions

View File

@ -20,4 +20,15 @@ extension KeyedDecodingContainer where Key : CodingKey {
public func decodeIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol? {
return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
}
public func decodeArray(codingKey: KeyedDecodingContainer<K>.Key) throws -> [MoleculeProtocol] {
guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else {
throw ModelRegistry.Error.decoderError
}
return models
}
public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> [MoleculeProtocol]? {
return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol]
}
}

View File

@ -18,7 +18,7 @@ public final class Color: Codable {
public private(set) var hex: String = ""
public private(set) var name: String = ""
// Color metadata
// Color metadata 🎨
public private(set) var red: CGFloat = 0
public private(set) var green: CGFloat = 0
public private(set) var blue: CGFloat = 0