Skip to content

Instantly share code, notes, and snippets.

@DanBrooker
Created March 12, 2015 01:10
Show Gist options
  • Save DanBrooker/ad9c51224ce2de19f73c to your computer and use it in GitHub Desktop.
Save DanBrooker/ad9c51224ce2de19f73c to your computer and use it in GitHub Desktop.
protocol DataModel {
}
protocol DataModelRelationships {
var relationships : [String: Array<DataModel>] { get }
}
protocol DataStore {
func add<T : DataModel>(element: T)
}
class ActualDataStore : DataStore {
func add<T : DataModel>(element: T) {
}
func add<U : protocol<DataModel,DataModelRelationships>>(element: U) {
updateRelationships(element)
}
func updateRelationships<U: protocol<DataModel,DataModelRelationships> >(element: U) {
println("this ran")
}
}
class AcutalObject : DataModel, DataModelRelationships {
var relationships : [String: Array<DataModel>] {
return ["something": []]
}
}
let object = AcutalObject()
let store = ActualDataStore()
store.add(object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment