Skip to content

Instantly share code, notes, and snippets.

@mortenbekditlevsen
Created August 9, 2018 07:20
Show Gist options
  • Save mortenbekditlevsen/f57b6006c491f605c5d0a32a119375d7 to your computer and use it in GitHub Desktop.
Save mortenbekditlevsen/f57b6006c491f605c5d0a32a119375d7 to your computer and use it in GitHub Desktop.
enum Root {}
enum ChatRooms {}
enum ChatRoom {}
enum Messages {}
struct Message: Codable {
// Our Message entity
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<ChatRooms> {
return append("chatrooms")
}
var configuration: Path<Configuration> {
return append("configuration")
}
}
extension Path where Element == ChatRooms {
func chatRoom(_ key: String) -> Path<ChatRoom> {
return append(key)
}
}
extension Path where Element == ChatRoom {
var name: Path<String> {
return append("name")
}
var messages: Path<Messages> {
return append("messages")
}
}
extension Path where Element == Messages {
func message(_ key: String) -> Path<Message> {
return append("message")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment