SHARE
TWEET

Untitled

a guest Aug 17th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @dynamicMemberLookup
  2. @dynamicCallable
  3. class Dsl<UrlsType> {
  4.    
  5.     private let urls: UrlsType
  6.     private var components: [String] = []
  7.    
  8.     init(urls: UrlsType) {
  9.         self.urls = urls
  10.     }
  11.    
  12.     subscript(dynamicMember keyPath: KeyPath<UrlsType, String>) -> Dsl {
  13.         components.append(urls[keyPath: keyPath])
  14.  
  15.         return self
  16.     }
  17.    
  18.     func dynamicallyCall(withArguments args: [String]) -> Dsl {
  19.         components.append(contentsOf: args)
  20.        
  21.         return self
  22.     }
  23.    
  24.     func make(replacements: [String: String] = [:]) -> String {
  25.         return components.joined(separator: "/")
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top