diff --git a/Code/ObjectMapping/RKObjectMapping.h b/Code/ObjectMapping/RKObjectMapping.h index 6a6ee566..15519e4a 100644 --- a/Code/ObjectMapping/RKObjectMapping.h +++ b/Code/ObjectMapping/RKObjectMapping.h @@ -94,7 +94,7 @@ @see `RKObjectParameterization` @see `RKObjectManager` */ -+ (instancetype)requestMapping; ++ (RKObjectMapping *)requestMapping; ///---------------------------------- /// @name Accessing Property Mappings diff --git a/Code/ObjectMapping/RKObjectMapping.m b/Code/ObjectMapping/RKObjectMapping.m index 5028843c..5f2305d8 100644 --- a/Code/ObjectMapping/RKObjectMapping.m +++ b/Code/ObjectMapping/RKObjectMapping.m @@ -115,8 +115,15 @@ static RKSourceToDesinationKeyTransformationBlock defaultSourceToDestinationKeyT return [[self alloc] initWithClass:objectClass]; } -+ (instancetype)requestMapping ++ (RKObjectMapping *)requestMapping { + if (! [self isEqual:[RKObjectMapping class]]) { + @throw [NSException exceptionWithName:NSInternalInconsistencyException + reason:[NSString stringWithFormat:@"`%@` is not meant to be invoked on `%@`. You probably want to invoke `[RKObjectMapping requestMapping]`.", + NSStringFromSelector(_cmd), + NSStringFromClass(self)] + userInfo:nil]; + } return [self mappingForClass:[NSMutableDictionary class]]; } diff --git a/Tests/Logic/CoreData/RKEntityMappingTest.m b/Tests/Logic/CoreData/RKEntityMappingTest.m index dd4b9dfa..bae58b61 100644 --- a/Tests/Logic/CoreData/RKEntityMappingTest.m +++ b/Tests/Logic/CoreData/RKEntityMappingTest.m @@ -540,4 +540,17 @@ expect([identificationAttributes valueForKey:@"name"]).to.equal(attributeNames); } +- (void)testInvokingRequestMappingRaisesHelpfulException +{ + NSException *caughtException = nil; + @try { + [RKEntityMapping requestMapping]; + } + @catch (NSException *exception) { + caughtException = exception; + } + expect(caughtException).notTo.beNil(); + expect(caughtException.reason).to.equal(@"`requestMapping` is not meant to be invoked on `RKEntityMapping`. You probably want to invoke `[RKObjectMapping requestMapping]`."); +} + @end