Skip to content

Commit

Permalink
better way to type Erase a Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsprint09 committed Jun 21, 2017
1 parent 24b7a6b commit 13a5e9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ public struct Resource<Model>: ResourceModeling {
}

public extension ResourceModeling {

/// Wrappes self into a `Resource` to hide away implementation details. This could be helpful when you think your typeinformation gets leaked.
///
/// - Returns: the wrapped ressource
@available(*, deprecated, message: "Use `init<R: ResourceModeling>(resource: R)`")
func wrapped() -> Resource<Model> {
return Resource(request: request, parse: parse)
}
}

public extension Resource {
init<R: ResourceModeling>(resource: R) where Model == R.Model {
self = Resource(request: resource.request, parse: resource.parse)
}
}

0 comments on commit 13a5e9f

Please sign in to comment.