Skip to content

Instantly share code, notes, and snippets.

@barbosa
Created April 25, 2016 15:37
Show Gist options
  • Select an option

  • Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 to your computer and use it in GitHub Desktop.

Select an option

Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 to your computer and use it in GitHub Desktop.
protocol Resource {
associatedtype ResourceFinderType
static var localObjects: ResourceFinderType { get }
}
extension Resource {
static var localObjects: ResourceFinder<Self> {
return ResourceFinder()
}
}
public protocol ResourceFinderProtocol {
associatedtype ResourceType
func all() -> [ResourceType]
}
struct ResourceFinder<T:Resource>: ResourceFinderProtocol {
func all() -> [T] {
return []
}
}
struct Model: Resource {}
Model.localObjects.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment