Created
April 25, 2016 15:37
-
-
Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 to your computer and use it in GitHub Desktop.
Revisions
-
barbosa created this gist
Apr 25, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ 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()