mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Reimplement connection matchers and add test case.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
//
|
||||
|
||||
#import <CoreData/CoreData.h>
|
||||
#import "RKDynamicMappingMatcher.h"
|
||||
|
||||
/**
|
||||
The `RKConnectionDescription` class describes a means for connecting a Core Data relationship. Connections can be established either by foreign key, in which case one or more attribute values on the source entity correspond to matching values on the destination entity, or by key path, in which case a key path is evaluated on the object graph to obtain a value for the relationship. Connection objects are used by instances of `RKRelationshipConnectionOperation` to connect a relationship of a given managed object.
|
||||
@@ -156,4 +157,9 @@
|
||||
*/
|
||||
@property (nonatomic, copy) NSPredicate *predicate;
|
||||
|
||||
/**
|
||||
An optional matcher that filters the source object to be connected.
|
||||
*/
|
||||
@property (nonatomic, strong) RKDynamicMappingMatcher* matcher;
|
||||
|
||||
@end
|
||||
|
||||
@@ -139,6 +139,10 @@ static NSDictionary *RKConnectionAttributeValuesWithObject(RKConnectionDescripti
|
||||
- (id)findConnected
|
||||
{
|
||||
id connectionResult = nil;
|
||||
|
||||
if (self.connection.matcher && ![self.connection.matcher matches:self.managedObject])
|
||||
return nil;
|
||||
|
||||
if ([self.connection isForeignKeyConnection]) {
|
||||
NSDictionary *attributeValues = RKConnectionAttributeValuesWithObject(self.connection, self.managedObject);
|
||||
NSSet *managedObjects = [self.managedObjectCache managedObjectsWithEntity:[self.connection.relationship destinationEntity]
|
||||
|
||||
Reference in New Issue
Block a user