Skip to content

Commit b9265dc

Browse files
Remove unnecessary custom codable in EDO
1 parent 517fdcd commit b9265dc

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

Sources/Cache/EntityDataObject.swift

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class EntityDataObject: Codable {
3131
private var serverValues = [String: AnyCodableValue]()
3232

3333
enum CodingKeys: String, CodingKey {
34-
case globalID = "guid"
34+
case guid = "_id"
3535
case serverValues = "sval"
3636
}
3737

@@ -84,28 +84,15 @@ class EntityDataObject: Codable {
8484
}
8585
}
8686

87-
// MARK: Encoding / Decoding support
88-
87+
// inline encodable data
88+
// used when trying to create a hydrated tree
8989
func encodableData() throws -> [String: AnyCodableValue] {
90-
var encodingValues = [String: AnyCodableValue]()
91-
encodingValues[GlobalIDKey] = .string(guid)
92-
encodingValues.merge(serverValues) { _, new in new }
93-
return encodingValues
94-
}
95-
96-
public func encode(to encoder: Encoder) throws {
97-
var container = encoder.container(keyedBy: CodingKeys.self)
98-
try container.encode(guid, forKey: .globalID)
99-
try container.encode(serverValues, forKey: .serverValues)
100-
}
101-
102-
required init(from decoder: Decoder) throws {
103-
let container = try decoder.container(keyedBy: CodingKeys.self)
104-
105-
let globalId = try container.decode(String.self, forKey: .globalID)
106-
guid = globalId
107-
108-
serverValues = try container.decode([String: AnyCodableValue].self, forKey: .serverValues)
90+
accessQueue.sync {
91+
var encodingValues = [String: AnyCodableValue]()
92+
encodingValues[GlobalIDKey] = .string(guid)
93+
encodingValues.merge(serverValues) { _, new in new }
94+
return encodingValues
95+
}
10996
}
11097
}
11198

0 commit comments

Comments
 (0)