KeyValueObjectMapping icon indicating copy to clipboard operation
KeyValueObjectMapping copied to clipboard

Support Parse configuration merging

Open akinsella opened this issue 12 years ago • 0 comments

Implementation provided may be improved, but it works well for the projects I work on.

1 - Interface

@interface DCParserConfiguration (XBAdditions)

-(void) mergeConfig:(DCParserConfiguration *) parserConfiguration;

@end

2 - Implementation

#import "DCParserConfiguration+XBAdditions.h"
#import "DCArrayMapping.h"


@implementation DCParserConfiguration (XBAdditions)

-(void) mergeConfig:(DCParserConfiguration *) parserConfiguration {

    for (DCObjectMapping * objectMapping in parserConfiguration.objectMappers) {
        DCArrayMapping * arrayMapping = [parserConfiguration arrayMapperForMapper:objectMapping];
        if (arrayMapping) {
            [self addArrayMapper:arrayMapping];
        }
        else{
            [self addObjectMapping:objectMapping];
        }
    }

    for (DCPropertyAggregator * propertyAggregator in parserConfiguration.aggregators) {
        [self addAggregator:propertyAggregator];
    }

    for (DCCustomInitialize * customInitialize in parserConfiguration.customInitializers) {
        [self addCustomInitializersObject:customInitialize];
    }

    for (DCCustomParser * customParser in parserConfiguration.customParsers) {
        [self addCustomParsersObject:customParser];
    }

}

@end

akinsella avatar May 01 '13 15:05 akinsella