Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active April 10, 2018 18:15
Show Gist options
  • Save Kdan/5bd4dbd9ccb42fbd949f11c6b032c366 to your computer and use it in GitHub Desktop.
Save Kdan/5bd4dbd9ccb42fbd949f11c6b032c366 to your computer and use it in GitHub Desktop.
/// To support a new class family, create an enum that conforms to this protocol and contains the different types.
protocol ClassFamily: Decodable {
/// The discriminator key.
static var discriminator: Discriminator { get }
/// Returns the class type of the object coresponding to the value.
func getType() -> AnyObject.Type
}
/// Discriminator key enum used to retrieve discriminator fields in JSON payloads.
enum Discriminator: String, CodingKey {
case type = "type"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment