Created
September 9, 2020 15:00
-
-
Save fortmarek/2be414f06c4d032769fb5f4265ed3cff to your computer and use it in GitHub Desktop.
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
enum CodingKeys: CodingKey { | |
case template | |
case dynamic(String) | |
init?(stringValue: String) { | |
switch stringValue { | |
case "template": | |
self = .template | |
case stringValue where Scaffold.attributes.contains(stringValue): | |
self = .dynamic(stringValue) | |
default: | |
return nil | |
} | |
} | |
var stringValue: String { | |
switch self { | |
case .template: | |
return "template" | |
case let .dynamic(name): | |
return name | |
} | |
} | |
// Not used | |
var intValue: Int? { nil } | |
init?(intValue _: Int) { nil } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment