Name changes and cleanup
This commit is contained in:
parent
77e2269062
commit
e41f3039e4
@ -57,7 +57,7 @@ import Foundation
|
||||
self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||
self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||
self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment)
|
||||
self.attributes = try typeContainer.decodeArrayIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel]
|
||||
self.attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel]
|
||||
self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
||||
self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
||||
self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
||||
|
||||
@ -13,22 +13,22 @@ extension KeyedDecodingContainer where Key : CodingKey {
|
||||
case moleculeName
|
||||
}
|
||||
|
||||
public func decode(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol {
|
||||
return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
|
||||
public func decodeMolecule(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol {
|
||||
return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
|
||||
}
|
||||
|
||||
public func decodeIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol? {
|
||||
return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
|
||||
public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol? {
|
||||
return try decodeModelIfPresent(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 {
|
||||
public func decodeMolecules(codingKey: KeyedDecodingContainer<K>.Key) throws -> [MoleculeProtocol] {
|
||||
guard let models = try decodeModels(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]
|
||||
return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol]
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,12 +29,12 @@ import Foundation
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
|
||||
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
||||
self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
||||
try container.encodeModelIfPresent(self.molecule, forKey: .molecule)
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,14 +27,14 @@ import Foundation
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
||||
self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule)
|
||||
self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
||||
try container.encodeModelIfPresent(self.molecule, forKey: .molecule)
|
||||
try container.encodeIfPresent(action, forKey: .action)
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,12 +24,12 @@ import Foundation
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
||||
self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
||||
try container.encodeModelIfPresent(self.molecule, forKey: .molecule)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user