Commenting

This commit is contained in:
Pfeil, Scott Robert 2019-12-18 16:10:15 -05:00
parent 46e76f0b47
commit 14c608c4a5

View File

@ -13,14 +13,17 @@ extension KeyedDecodingContainer where Key : CodingKey {
case moleculeName
}
/// Decodes the molecule model with the given coding key based on moleculeName
public func decodeMolecule(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol {
return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
}
/// Decodes the molecule model with the given coding key based on moleculeName, optional
public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> MoleculeProtocol? {
return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName)
}
/// Decodes the list of molecule models with the given coding key based on moleculeName
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
@ -28,6 +31,7 @@ extension KeyedDecodingContainer where Key : CodingKey {
return models
}
/// Decodes the list of molecule models with the given coding key based on moleculeName, optional
public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> [MoleculeProtocol]? {
return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol]
}