We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
CodingKey
1 parent 92097a1 commit ed29839Copy full SHA for ed29839
1 file changed
Sources/CoreModel/Extensions/CodingKey.swift
@@ -0,0 +1,28 @@
1
+//
2
+// CodingKey.swift
3
4
5
+// Created by Alsey Coleman Miller on 8/18/23.
6
7
+
8
+internal extension Sequence where Element == CodingKey {
9
10
+ /// KVC path string for current coding path.
11
+ var path: String {
12
+ return reduce("", { $0 + "\($0.isEmpty ? "" : ".")" + $1.stringValue })
13
+ }
14
+}
15
16
+internal extension CodingKey {
17
18
+ static var sanitizedName: String {
19
20
+ let rawName = String(reflecting: self)
21
+ var elements = rawName.split(separator: ".")
22
+ guard elements.count > 2
23
+ else { return rawName }
24
+ elements.removeFirst()
25
+ elements.removeAll { $0.contains("(unknown context") }
26
+ return elements.reduce("", { $0 + ($0.isEmpty ? "" : ".") + $1 })
27
28
0 commit comments