Skip to content

Instantly share code, notes, and snippets.

@emenegro
Last active March 21, 2017 21:04
Show Gist options
  • Save emenegro/f4e5a6bfc30c387de84c703a2f47e697 to your computer and use it in GitHub Desktop.
Save emenegro/f4e5a6bfc30c387de84c703a2f47e697 to your computer and use it in GitHub Desktop.
extension OfflineActionBuilder: RequestStep, DataStep, CommonsStep, CacheCommonsStep, GetCommonsStep {
func toCache(_ request: OfflineRequestConvertible) -> DataStep {
action.type = .cache
action.request = request
return self as DataStep
}
func toGet(_ request: OfflineRequestConvertible) -> GetCommonsStep {
action.type = .get
action.request = request
return self as GetCommonsStep
}
func toDelete(_ request: OfflineRequestConvertible) -> CommonsStep {
action.type = .delete
action.request = request
return self as CommonsStep
}
func data(_ data: Data) -> CacheCommonsStep {
action.data = data
return self as CacheCommonsStep
}
func forId(_ id: String) -> Self {
action.id = id
return self
}
func withEncryptionKey(_ encryptionKey: String) -> Self {
action.encryptionKey = encryptionKey
return self
}
func keepingAliveUntil(_ date: Date) -> Self {
action.keepAliveUntil = date
return self
}
func ifBefore(_ date: Date) -> Self {
action.ifBefore = date
return self
}
func build() -> OfflineAction {
return action
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment