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

Relationship Properties

Uniquing Properties

Relationship Methods

Properties

dictionary

The dictionary being used to populate this proto record.

@property (nonatomic, copy) NSDictionary *dictionary

Discussion

The dictionary being used to populate this proto record.

Declared In

MMRecordProtoRecord.h

entity

The entity type for this proto record.

@property (nonatomic, strong, readonly) NSEntityDescription *entity

Discussion

The entity type for this proto record.

Declared In

MMRecordProtoRecord.h

hasRelationshipPrimarykey

Property for defining whether or not this record has a relationship as its primary key.

@property (nonatomic) BOOL hasRelationshipPrimarykey

Return 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.h

primaryAttributeDescription

The primary key attribute description for this proto record.

@property (nonatomic, strong) NSAttributeDescription *primaryAttributeDescription

Discussion

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.h

primaryKeyValue

The primary key value for this proto record. Typically a string or number.

@property (nonatomic, strong) id primaryKeyValue

Discussion

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.h

record

The record instance represented by this proto record.

@property (nonatomic, strong) MMRecord *record

Discussion

The record instance represented by this proto record.

Declared In

MMRecordProtoRecord.h

relationshipDescriptions

The relationship descriptions for this proto record’s type of entity.

@property (nonatomic, strong, readonly) NSArray *relationshipDescriptions

Discussion

The relationship descriptions for this proto record’s type of entity.

Declared In

MMRecordProtoRecord.h

relationshipPrimaryKeyProto

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 *relationshipPrimaryKeyProto

Discussion

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.h

relationshipProtos

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 *relationshipProtos

Discussion

An array of relationship proto records that define the objects that will be associated as relationships on this proto record.

Declared In

MMRecordProtoRecord.h

representation

The representation used to describe this type of proto record.

@property (nonatomic, strong, readonly) MMRecordRepresentation *representation

Discussion

The representation used to describe this type of proto record.

Declared In

MMRecordProtoRecord.h

Class Methods

protoRecordWithDictionary:entity:representation:

Designated Initializer

+ (MMRecordProtoRecord *)protoRecordWithDictionary:(NSDictionary *)dictionary entity:(NSEntityDescription *)entity representation:(MMRecordRepresentation *)representation

Parameters

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.h

Instance Methods

addRelationshipProto:forRelationshipDescription:

This method is used to associate another proto as having a relationship to this one.

- (void)addRelationshipProto:(MMRecordProtoRecord *)relationshipProto forRelationshipDescription:(NSRelationshipDescription *)relationshipDescription

Parameters

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.h

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.

- (BOOL)canAccomodateAdditionalProtoRecordForRelationshipDescription:(NSRelationshipDescription *)relationshipDescription

Return 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.h

relationshipProtoRecordsForRelationshipDescription:

Returns the proto records for a given relationship description.

- (NSArray *)relationshipProtoRecordsForRelationshipDescription:(NSRelationshipDescription *)relationshipDescription

Parameters

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