-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access node tag during decoding #265
Comments
How do we |
An option that would work for me, is to be able to up front register specific types for specific tags. I'm not sure that this would be practical for @tjprescott 's case, though. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have a data model schema that is using verbatim tags in YAML to indicate polymorphism. Note the protocol property in the below YAML snippet.
Here is
Protocols.swift
:So under
protocol
, thehttp
property could be one of a few different types. Here is the model forHttpParameter
(as indicated in the snippet):This requires us to supply the following methods to
Protocols
:The tag appears in the decoder object, and we would like to be able to access that info, as this would tell us which polymorphic type to encode and decode. As it stands, we have to just keep trying each possibility until one or none worked. The problem we have is that the
_Decoder
class and itsnode
property are both private. We can print them in the debugger and see that they are viewable, but we can't programmatically access them in our methods. Is there a way to access the tag during the call toinit(from decoder:)
?cc/ @sacheu
The text was updated successfully, but these errors were encountered: