Created
May 9, 2018 22:00
-
-
Save IgorMuzyka/f4248dab875cb67d5842267c34390c31 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
extension Restorable { | |
public static func restore(from path: Path) throws -> Self { | |
return try Self.read(from: path) | |
} | |
} | |
extension Persistable { | |
@discardableResult | |
public func persist(to directory: Path, override shouldOverride: Bool = true) throws -> File<Self> { | |
let path = directory + (fileName + Self.fileExtension) | |
let file = File<Self>(path: path) | |
if file.exists && shouldOverride { try file.delete() } | |
try file.create() | |
try write(to: file.path) | |
return file | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment