Created
November 18, 2025 05:07
-
-
Save robertvunabandi/527ac0a1c8ba8295ba2006741b95e2a6 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
| // | |
| // DataType.swift | |
| // Reading Journal | |
| // | |
| // | |
| import Foundation | |
| enum DataType: CaseIterable { | |
| case beta | |
| /// `authors` is for ``MAuthor`` models. | |
| case authors | |
| case feedback | |
| case sources | |
| case sourceSections | |
| case quotes | |
| case search | |
| static func flushAll() { | |
| LOG.info("Flushing all DataStores", #line) | |
| allCases.forEach { $0.storeType().flush() } | |
| } | |
| private func storeType() -> any DataStore.Type { | |
| let type = getStoreType() | |
| assert( | |
| type.Enum == self, | |
| "type.Enum (\(type.Enum)) doesn't match .getStoreType() (\(type))" | |
| ) | |
| return type | |
| } | |
| private func getStoreType() -> any DataStore.Type { | |
| switch self { | |
| case .authors: | |
| AuthorsDataStore.self | |
| case .beta: | |
| BetaDataStore.self | |
| case .feedback: | |
| FeedbackDataStore.self | |
| case .sources: | |
| SourcesDataStore.self | |
| case .sourceSections: | |
| SourceSectionsDataStore.self | |
| case .quotes: | |
| QuotesDataStore.self | |
| case .search: | |
| SearchDataStore.self | |
| } | |
| } | |
| private static let LOG = Tools.getLogger(filename: #file) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment