I have a Media model, and Image,Video and Audio models that inherit from media. I am using RestKit to map the data from an API(rails app).
Is there a way to do a conditional mapping using RestKit? If my response contains a media_type of video, then use the Video model mapping otherwise the image mapping etc.
Update
RKDynamicMapping *dynamicMapping = [RKDynamicMapping new];
RKObjectMapping *videoMapping = [RKObjectMapping mappingForClass:[MMXMediaVideo class]];
RKObjectMapping *imageMapping = [RKObjectMapping mappingForClass:[MMXMediaImage class]];
[dynamicMapping addMatcher:[RKObjectMappingMatcher matcherWithKeyPath:@"medium_type" expectedValue:@"video" objectMapping: videoMapping]];
[dynamicMapping addMatcher:[RKObjectMappingMatcher matcherWithKeyPath:@"medium_type" expectedValue:@"image" objectMapping:imageMapping]];
How do I add a mapping method to video or image mapping?