Skip to content

Instantly share code, notes, and snippets.

@PattoMotto
Last active July 9, 2018 11:40
Show Gist options
  • Save PattoMotto/3a1cfd2538eed6c6f1a82978a555aecf to your computer and use it in GitHub Desktop.
Save PattoMotto/3a1cfd2538eed6c6f1a82978a555aecf to your computer and use it in GitHub Desktop.
struct Recipe: Codable {
let identifier: String
let name: String
let instruction: [String]
}
protocol CookBookDataManager {
func getRecipe(_ identifier: String) -> Recipe?
}
final class CookBookDataManagerImpl: CookBookDataManager {
private lazy var recipes: [Recipe] = {
return [
Recipe(
identifier: "foo",
name: "Foo Bar",
instruction: ["Foo", "Bar"]
)
]
}()
func getRecipe(_ identifier: String) -> Recipe? {
return recipes.filter{ $0.identifier == identifier }.first
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment