Created
April 25, 2016 15:37
-
-
Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 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
| 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