Created
August 9, 2018 07:20
-
-
Save mortenbekditlevsen/f57b6006c491f605c5d0a32a119375d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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