-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add [String:Any] support to identify & track (#94)
- Loading branch information
1 parent
bba303a
commit 5a220c4
Showing
11 changed files
with
191 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import Foundation | ||
|
||
public struct StringAnyEncodable: Encodable { | ||
private let data: [String:AnyEncodable] | ||
private let data: [String: AnyEncodable] | ||
|
||
public init(_ data: [String:Any]) { | ||
var d = [String:AnyEncodable]() | ||
for (k, v) in data { | ||
switch v{ | ||
public init(_ data: [String: Any]) { | ||
var builtValue = [String: AnyEncodable]() | ||
for (key, value) in data { | ||
switch value { | ||
case let enc as Encodable: | ||
d[k] = AnyEncodable(enc) | ||
case let dict as [String:Any]: | ||
d[k] = AnyEncodable(StringAnyEncodable(dict)) | ||
builtValue[key] = AnyEncodable(enc) | ||
case let dict as [String: Any]: | ||
builtValue[key] = AnyEncodable(StringAnyEncodable(dict)) | ||
default: | ||
// XXX: logger error | ||
continue | ||
} | ||
} | ||
self.data = d | ||
self.data = builtValue | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
try self.data.encode(to: encoder) | ||
try data.encode(to: encoder) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.