Skip to content

Commit ca84af9

Browse files
author
Guillermo Moraleda
authored
fix: cleanup (#419)
1 parent 81cb107 commit ca84af9

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

Sources/Contentful/ArrayResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ extension HomogeneousArrayResponse: Decodable {
147147
"""
148148
throw SDKError.unparseableJSON(data: nil, errorMessage: errorMessage)
149149
}
150-
let entryDecodable = try entryDecodableType.popEntryDecodable(from: &entriesJSONContainer)
150+
let entryDecodable = try entriesJSONContainer.decode(entryDecodableType)
151151
entries.append(entryDecodable)
152152
}
153153

@@ -331,7 +331,7 @@ extension KeyedDecodingContainer {
331331
// For includes, if the type of this entry isn't defined by the user, we skip serialization.
332332
if let type = contentTypes[contentTypeInfo.id] {
333333
do {
334-
let entryModellable = try type.popEntryDecodable(from: &entriesJSONContainer)
334+
let entryModellable = try entriesJSONContainer.decode(type)
335335
entries.append(entryModellable)
336336
} catch {
337337
if throwIfNotPresent {

Sources/Contentful/Date.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public extension Date {
5353
let dateString = try container.decode(String.self)
5454

5555
let timeZone = decoder.timeZone
56-
let formatter = Date.iso8601Formatter(timeZone: timeZone)
5756

5857
for format in Date.supportedFormats {
5958
let formatter = DateFormatterCache.shared.get(format, timeZone: timeZone)

Sources/Contentful/Decodable.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ public extension JSONDecoder {
7979
}
8080
}
8181

82-
public extension Decodable where Self: EntryDecodable {
83-
// This is a magic workaround for the fact that dynamic metatypes cannot be passed into
84-
// initializers such as UnkeyedDecodingContainer.decode(Decodable.Type), yet static methods CAN
85-
// be called on metatypes. (Visitor pattern)
86-
static func popEntryDecodable(from container: inout UnkeyedDecodingContainer) throws -> Self {
87-
let entryDecodable = try container.decode(self)
88-
return entryDecodable
89-
}
90-
}
91-
9282
extension Decodable where Self: AssetDecodable {
9383
static func popAssetDecodable(from container: inout UnkeyedDecodingContainer) throws -> Self {
9484
let assetDecodable = try container.decode(self)

0 commit comments

Comments
 (0)