Skip to content

Instantly share code, notes, and snippets.

@mortenbekditlevsen
Last active August 9, 2018 08:13
Show Gist options
  • Save mortenbekditlevsen/f45f3ad746167842ac72bb7f94f9b121 to your computer and use it in GitHub Desktop.
Save mortenbekditlevsen/f45f3ad746167842ac72bb7f94f9b121 to your computer and use it in GitHub Desktop.
enum Root {}
enum ChatRoom {}
struct Message: Codable {
var header: String
var body: String
}
struct Configuration: Codable {
// Our actual Configuration entity
var welcomeMessage: String
}
extension Path where Element == Root {
init() {
self.init([])
}
}
extension Path where Element == Root {
var chatrooms: Path<ChatRoom>.Collection {
return append("chatrooms")
}
var configuration: Path<Configuration> {
return append("configuration")
}
}
extension Path where Element == ChatRoom {
var name: Path<String> {
return append("name")
}
var messages: Path<Message>.Collection {
return append("messages")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment