Skip to content

Instantly share code, notes, and snippets.

@cvasilak
Created November 16, 2012 09:08
Show Gist options
  • Save cvasilak/4085708 to your computer and use it in GitHub Desktop.
Save cvasilak/4085708 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@protocol AGEntity <NSObject>
@optional
-(NSDictionary*) mapping;
@end
@inteface Customer: NSOBject<AGEntity>
@property(nonatomic, copy) NSString *name
-(NSDictionary)mapping {
// user describes ANY relations and Array types
}
-(id) initWithConfig:(id<AGPipeConfig>) pipeConfig entity:(id<AGEntity>)entity {
...
NSDictionary *mapping = [entity mapping];
if (mapping == nil) { // no mapping
_parser = [DCKeyValueObjectMapping mapperForClass: [_entity class]];
} else {
for (NSString* name in [mapping allKeys]) {
DCArrayMapping *mapper = [DCArrayMapping mapperForClassElements: :[mapping objectForkey:name] forAttribute:name]
onClass:[_entity class]];
DCParserConfiguration *config = [DCParserConfiguration configuration];
[config addArrayMapper:mapper];
}
_parser = [[DCKeyValueObjectMapping mapperForClass:[_entity class] andConfiguration:configuration];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment