MMRecordProtoRecord Class Reference
| Inherits from | NSObject |
| Declared in | MMRecordProtoRecord.h MMRecordProtoRecord.m |
Overview
This class represents a record in its prototype state before it hatches into a full living breathing MMRecord. Proto records are typically created to match the contents of a request’s response object. If your response object contains an array of 20 records of type “user”, then you would create 20 proto records for the user entity. A proto record contains the entity whose type it represents and the dictionary it is based on from the response object. It is also responsible for maintaining the association between itself and other proto records that represent the relationships to it’s fully formed record. One subtle thing to keep in mind is that only one proto record should be created for each unique record in the response object. The proto record is not responsible for that, but it is an important consideration for a user of this class to consider. This class is responsible for populating records with their given dictionary, as well as establishing relationships to it’s record.
Note: when the value representing a relationship is a single string or number that MMRecord will convert that string or number into a dictionary with that value, and they primary key identified for that targetted relationship’s entity. That means that the representation of a proto record will always be in the form of a dictionary, even if the response object form is a string or a number.
Tasks
Population Properties
-
recordThe record instance represented by this proto record.
property -
dictionaryThe dictionary being used to populate this proto record.
property -
entityThe entity type for this proto record.
property -
representationThe representation used to describe this type of proto record.
property
Relationship Properties
-
relationshipProtosAn array of relationship proto records that define the objects that will be associated as relationships on this proto record.
property -
relationshipDescriptionsThe relationship descriptions for this proto record’s type of entity.
property
Uniquing Properties
-
primaryKeyValueThe primary key value for this proto record. Typically a string or number.
property -
primaryAttributeDescriptionThe primary key attribute description for this proto record.
property -
relationshipPrimaryKeyProtoThe relationship primary key proto is used to reference the proto that can uniquely identify this record using one of its relationships.
property -
hasRelationshipPrimarykeyProperty for defining whether or not this record has a relationship as its primary key.
property -
+ protoRecordWithDictionary:entity:representation:Designated Initializer
Relationship Methods
-
– addRelationshipProto:forRelationshipDescription:This method is used to associate another proto as having a relationship to this one.
-
– canAccomodateAdditionalProtoRecordForRelationshipDescription:This method can be used to tell whether or not there is already a valid relationshipProtoRecord for a given relationship description. This returns NO if there is already a relationshipProtoRecord for that relationship. In the case of to-many relationships this will always return YES.
-
– relationshipProtoRecordsForRelationshipDescription:Returns the proto records for a given relationship description.
Properties
dictionary
The dictionary being used to populate this proto record.
@property (nonatomic, copy) NSDictionary *dictionaryDiscussion
The dictionary being used to populate this proto record.
Declared In
MMRecordProtoRecord.hentity
The entity type for this proto record.
@property (nonatomic, strong, readonly) NSEntityDescription *entityDiscussion
The entity type for this proto record.
Declared In
MMRecordProtoRecord.hhasRelationshipPrimarykey
Property for defining whether or not this record has a relationship as its primary key.
@property (nonatomic) BOOL hasRelationshipPrimarykeyReturn Value
YES if the proto record has a relationship as its primary key.
Discussion
Property for defining whether or not this record has a relationship as its primary key.
Declared In
MMRecordProtoRecord.hprimaryAttributeDescription
The primary key attribute description for this proto record.
@property (nonatomic, strong) NSAttributeDescription *primaryAttributeDescriptionDiscussion
The primary key attribute description for this proto record.
Warning: This will be nil if the proto record uses a relationship as its primary key.
Declared In
MMRecordProtoRecord.hprimaryKeyValue
The primary key value for this proto record. Typically a string or number.
@property (nonatomic, strong) id primaryKeyValueDiscussion
The primary key value for this proto record. Typically a string or number.
Warning: This will be nil if the proto record uses a relationship as its primary key.
Declared In
MMRecordProtoRecord.hrecord
The record instance represented by this proto record.
@property (nonatomic, strong) MMRecord *recordDiscussion
The record instance represented by this proto record.
Declared In
MMRecordProtoRecord.hrelationshipDescriptions
The relationship descriptions for this proto record’s type of entity.
@property (nonatomic, strong, readonly) NSArray *relationshipDescriptionsDiscussion
The relationship descriptions for this proto record’s type of entity.
Declared In
MMRecordProtoRecord.hrelationshipPrimaryKeyProto
The relationship primary key proto is used to reference the proto that can uniquely identify this record using one of its relationships.
@property (nonatomic, weak) MMRecordProtoRecord *relationshipPrimaryKeyProtoDiscussion
The relationship primary key proto is used to reference the proto that can uniquely identify this record using one of its relationships.
Warning: This will be nil if the proto record does not use a relationship as its primary key.
Declared In
MMRecordProtoRecord.hrelationshipProtos
An array of relationship proto records that define the objects that will be associated as relationships on this proto record.
@property (nonatomic, strong, readonly) NSArray *relationshipProtosDiscussion
An array of relationship proto records that define the objects that will be associated as relationships on this proto record.
Declared In
MMRecordProtoRecord.hClass Methods
protoRecordWithDictionary:entity:representation:
Designated Initializer
+ (MMRecordProtoRecord *)protoRecordWithDictionary:(NSDictionary *)dictionary entity:(NSEntityDescription *)entity representation:(MMRecordRepresentation *)representationParameters
- dictionary
The dictionary used to populate the proto record.
- entity
The type of record this describes.
- representation
The representation used to describe this proto record.
Discussion
Designated Initializer
This method is used to instantiate a base proto record. The proto record is configured with a dictionary that is used to populate the record, an entity to describe the type of record, and a representation that describes how the record can be populated from that dictionary. This method should always be used to instantiate a proto record.
Declared In
MMRecordProtoRecord.hInstance Methods
addRelationshipProto:forRelationshipDescription:
This method is used to associate another proto as having a relationship to this one.
- (void)addRelationshipProto:(MMRecordProtoRecord *)relationshipProto forRelationshipDescription:(NSRelationshipDescription *)relationshipDescriptionParameters
- relationshipProto
The proto record representing the relationship.
- relationshipDescription
The relationship on this proto to associate the proto with.
Discussion
This method is used to associate another proto as having a relationship to this one.
Declared In
MMRecordProtoRecord.hcanAccomodateAdditionalProtoRecordForRelationshipDescription:
This method can be used to tell whether or not there is already a valid relationshipProtoRecord for a given relationship description. This returns NO if there is already a relationshipProtoRecord for that relationship. In the case of to-many relationships this will always return YES.
- (BOOL)canAccomodateAdditionalProtoRecordForRelationshipDescription:(NSRelationshipDescription *)relationshipDescriptionReturn Value
NO if there is already a valid relationshipProtoRecord for a given relationshipDescription @discussion In the case of to-many relationships this will always return YES.
Discussion
This method can be used to tell whether or not there is already a valid relationshipProtoRecord for a given relationship description. This returns NO if there is already a relationshipProtoRecord for that relationship. In the case of to-many relationships this will always return YES.
Declared In
MMRecordProtoRecord.hrelationshipProtoRecordsForRelationshipDescription:
Returns the proto records for a given relationship description.
- (NSArray *)relationshipProtoRecordsForRelationshipDescription:(NSRelationshipDescription *)relationshipDescriptionParameters
- relationshipDescription
The relationship to request proto records for.
Return Value
An array of proto records for the given relationship.
Discussion
Returns the proto records for a given relationship description.
Declared In
MMRecordProtoRecord.h