Added support for selecting object mapping using pattern matching on resourcePath.

This commit is contained in:
Blake Watters
2012-01-16 23:36:18 -05:00
parent 3a8221aa08
commit 7a1dfd0857
4 changed files with 64 additions and 5 deletions

View File

@@ -200,15 +200,24 @@
return result;
}
- (RKObjectMapping *)configuredObjectMapping {
if (self.objectMapping) {
return self.objectMapping;
}
return [self.mappingProvider objectMappingForResourcePath:self.resourcePath];
}
- (RKObjectMappingResult*)performMapping:(NSError**)error {
NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping should occur on a background thread");
RKObjectMappingProvider* mappingProvider;
if (self.objectMapping) {
NSString* rootKeyPath = self.objectMapping.rootKeyPath ? self.objectMapping.rootKeyPath : @"";
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);
mappingProvider = [RKObjectMappingProvider mappingProvider];
[mappingProvider setMapping:self.objectMapping forKeyPath:rootKeyPath];
[mappingProvider setMapping:configuredObjectMapping forKeyPath:rootKeyPath];
} else {
RKLogDebug(@"No object mapping provider, using mapping provider from parent object manager to perform KVC mapping");
mappingProvider = self.mappingProvider;

View File

@@ -3,7 +3,7 @@
// RestKit
//
// Created by Blake Watters on 10/18/10.
// Copyright 2010 Two Toasters
// Copyright 2010 RestKit
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@@ -3,7 +3,7 @@
// RestKit
//
// Created by Blake Watters on 10/18/10.
// Copyright 2010 Two Toasters
// Copyright 2010 RestKit
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.