Apply rootKeyPath within the mapper rather than the object loader

This commit is contained in:
Blake Watters
2012-01-18 08:45:34 -05:00
parent 7c5ad95816
commit 4bd12ea987
4 changed files with 7 additions and 4 deletions

View File

@@ -214,10 +214,9 @@
RKObjectMappingProvider* mappingProvider;
RKObjectMapping *configuredObjectMapping = [self configuredObjectMapping];
if (configuredObjectMapping) {
NSString* rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @"";
RKLogDebug(@"Found directly configured object mapping, creating temporary mapping provider for keyPath %@", rootKeyPath);
if (configuredObjectMapping) {
mappingProvider = [RKObjectMappingProvider mappingProvider];
NSString *rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @"";
[mappingProvider setMapping:configuredObjectMapping forKeyPath:rootKeyPath];
} else {
RKLogDebug(@"No object mapping provider, using mapping provider from parent object manager to perform KVC mapping");

View File

@@ -334,7 +334,9 @@
} else if ([mappingsForContext conformsToProtocol:@protocol(RKObjectMappingDefinition)]) {
id mappableData = self.sourceObject;
if ([mappingsForContext respondsToSelector:@selector(rootKeyPath)] && [mappingsForContext rootKeyPath] != nil) {
mappableData = [self.sourceObject valueForKeyPath:[mappingsForContext rootKeyPath]];
NSString* rootKeyPath = [mappingsForContext rootKeyPath];
mappableData = [self.sourceObject valueForKeyPath:rootKeyPath];
RKLogDebug(@"Selected object mapping has rootKeyPath. Apply valueForKeyPath to mappable data: %@", rootKeyPath);
}
if (mappableData) {

View File

@@ -30,6 +30,7 @@
#import "RKObjectMapper_Private.h"
#import "RKObjectMapperError.h"
#import "RKDynamicMappingModels.h"
#import "RKObjectMappingProvider+Contexts.h"
// Managed Object Serialization Specific
#import "RKHuman.h"

View File

@@ -23,6 +23,7 @@
#import "RKManagedObjectStore.h"
#import "RKSpecResponseLoader.h"
#import "RKManagedObjectMapping.h"
#import "RKObjectMappingProvider+Contexts.h"
#import "RKObjectMappingProvider.h"
#import "RKHuman.h"
#import "RKCat.h"