File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Firestore/Swift/Source/Codable Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 17
17
import FirebaseFirestore
18
18
import FirebaseSharedSwift
19
19
20
- let documentRefUserInfoKey =
21
- CodingUserInfoKey ( rawValue: " DocumentRefUserInfoKey " ) !
20
+ extension CodingUserInfoKey {
21
+ static let documentRefUserInfoKey =
22
+ CodingUserInfoKey ( rawValue: " DocumentRefUserInfoKey " ) !
23
+ }
22
24
23
25
/// A type that can initialize itself from a Firestore `DocumentReference`,
24
26
/// which makes it suitable for use with the `@DocumentID` property wrapper.
@@ -105,9 +107,10 @@ public struct DocumentID<Value: DocumentIDWrappable & Codable>:
105
107
// MARK: - `Codable` implementation.
106
108
107
109
public init ( from decoder: Decoder ) throws {
108
- guard let reference = decoder. userInfo [ documentRefUserInfoKey] as? DocumentReference else {
110
+ guard let reference = decoder
111
+ . userInfo [ CodingUserInfoKey . documentRefUserInfoKey] as? DocumentReference else {
109
112
throw FirestoreDecodingError . decodingIsNotSupported (
110
- " Could not find DocumentReference for user info key: \( documentRefUserInfoKey) "
113
+ " Could not find DocumentReference for user info key: \( CodingUserInfoKey . documentRefUserInfoKey) "
111
114
)
112
115
}
113
116
try self . init ( from: reference)
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public extension Firestore {
90
90
public func decode< T: Decodable > ( _ t: T . Type , from data: Any ,
91
91
in reference: DocumentReference ? ) throws -> T {
92
92
if let reference = reference {
93
- userInfo [ documentRefUserInfoKey] = reference
93
+ userInfo [ CodingUserInfoKey . documentRefUserInfoKey] = reference
94
94
}
95
95
return try decode ( T . self, from: data)
96
96
}
You can’t perform that action at this time.
0 commit comments