This commit is contained in:
Suresh, Kamlesh 2019-11-19 15:37:53 -05:00
parent d38b521c66
commit 1b99abdb6e

View File

@ -25,7 +25,7 @@ public struct ModelRegistry {
}
extension KeyedDecodingContainer where Key : CodingKey{
extension KeyedDecodingContainer where Key: CodingKey {
private enum TypeCodingKey: String, CodingKey {
case actionMap
@ -44,10 +44,6 @@ extension KeyedDecodingContainer where Key : CodingKey{
return m
}
public func decode(codingKey: KeyedDecodingContainer<K>.Key) throws -> ActionMapModel {
return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.actionMap)
}
//MARK: - DecodeIfPresent
public func decodeIfPresent<T, C:CodingKey>(codingKey: KeyedDecodingContainer<K>.Key, typeCodingKey: C) throws -> T? {
@ -73,14 +69,10 @@ extension KeyedDecodingContainer where Key : CodingKey{
}
return m
}
public func decodeIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> ActionMapModel? {
return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.actionMap)
}
}
extension KeyedEncodingContainer where Key : CodingKey {
extension KeyedEncodingContainer where Key: CodingKey {
public mutating func encodeIfPresent(_ value: Model?, forKey key: KeyedEncodingContainer<K>.Key) throws {
if let v = value {