Created
August 6, 2019 07:09
-
-
Save azonov/67215014b21006c9b930c2cdc1549582 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
@dynamicMemberLookup | |
@dynamicCallable | |
class Dsl<UrlsType> { | |
private let urls: UrlsType | |
private var components: [String] = [] | |
init(urls: UrlsType) { | |
self.urls = urls | |
} | |
subscript(dynamicMember keyPath: KeyPath<UrlsType, String>) -> Dsl { | |
components.append(urls[keyPath: keyPath]) | |
return self | |
} | |
func dynamicallyCall(withArguments args: [String]) -> Dsl { | |
components.append(contentsOf: args) | |
return self | |
} | |
func make(replacements: [String: String] = [:]) -> String { | |
return components.joined(separator: "/") | |
} | |
} |
Author
azonov
commented
Aug 6, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment