Compare commits

...

2 Commits

Author SHA1 Message Date
Mathew Polzin fcc1796731 Expose Entity properties on EntityType protocol. 2018-11-27 18:58:48 -08:00
Mathew Polzin 921bcef05d Ids are now Hashable 2018-11-27 18:39:57 -08:00
2 changed files with 14 additions and 2 deletions
+12
View File
@@ -43,6 +43,18 @@ public protocol EntityType: PrimaryResource {
typealias Attributes = Description.Attributes
typealias Relationships = Description.Relationships
/// The `Entity`'s Id. This can be of type `Unidentified` if
/// the entity is being created clientside and the
/// server is being asked to create a unique Id. Otherwise,
/// this should be of a type conforming to `IdType`.
var id: Identifier { get }
/// The JSON API compliant attributes of this `Entity`.
var attributes: Attributes { get }
/// The JSON API compliant relationships of this `Entity`.
var relationships: Relationships { get }
}
/// An `Entity` is a single model type that can be
+2 -2
View File
@@ -8,7 +8,7 @@
/// Any type that you would like to be encoded to and
/// decoded from JSON API ids should conform to this
/// protocol. Conformance for `String` is given.
public protocol RawIdType: Codable, Equatable {}
public protocol RawIdType: Codable, Hashable {}
/// If you would like to be able to create new
/// Entities with Ids backed by a RawIdType then
@@ -32,7 +32,7 @@ public struct Unidentified<EntityDescription: JSONAPI.EntityDescription>: Identi
public var description: String { return "Id(Unidentified)" }
}
public protocol IdType: Identifier, CustomStringConvertible {
public protocol IdType: Identifier, Hashable, CustomStringConvertible {
associatedtype RawType: RawIdType
var rawValue: RawType { get }