Implementation of Object Mapping 2.0 design:

* Removed RestKit from inheritance hierarchy
  * Mappings are implemented as concrete classes
  * Mapper is much more flexible & powerful
  * Much more robust error handling
  * Serialization is reimplemented as an object mapping operation
  * Added ability to serialize to JSON natively
  * Reworked Core Data integration
  * Simplified the codebase substantially
This commit is contained in:
Blake Watters
2011-04-23 18:32:33 -04:00
parent 3a76780f76
commit f3c0995d5e
244 changed files with 13499 additions and 3073 deletions

View File

@@ -30,21 +30,6 @@ static DBUser* currentUser = nil;
@synthesize passwordConfirmation = _passwordConfirmation;
@synthesize delegate = _delegate;
/**
* The property mapping dictionary. This method declares how elements in the JSON
* are mapped to properties on the object
*/
+ (NSDictionary*)elementToPropertyMappings {
return [NSDictionary dictionaryWithKeysAndObjects:
@"id", @"userID",
@"email", @"email",
@"username", @"username",
@"single_access_token", @"singleAccessToken",
@"password", @"password",
@"password_confirmation", @"passwordConfirmation",
nil];
}
/**
* Informs RestKit which property contains the primary key for identifying
* this object. This is used to ensure that existing objects are updated during mapping
@@ -61,7 +46,7 @@ static DBUser* currentUser = nil;
if (nil == currentUser) {
id userID = [[NSUserDefaults standardUserDefaults] objectForKey:kDBUserCurrentUserIDDefaultsKey];
if (userID) {
currentUser = [self objectWithPrimaryKeyValue:userID];
currentUser = [self findFirstByAttribute:@"userID" withValue:userID];
} else {
currentUser = [self object];
}
@@ -100,8 +85,11 @@ static DBUser* currentUser = nil;
RKObjectLoader* objectLoader = [[RKObjectManager sharedManager] objectLoaderWithResourcePath:@"/login" delegate:self];
objectLoader.method = RKRequestMethodPOST;
objectLoader.params = [NSDictionary dictionaryWithKeysAndObjects:@"user[username]", username, @"user[password]", password, nil];
objectLoader.params = [NSDictionary dictionaryWithKeysAndObjects:@"user[username]", username, @"user[password]", password, nil];
objectLoader.targetObject = self;
// TODO: Temporary to work around bug in Rails serialization on the Heroku app
objectLoader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForKeyPath:@"user"];
[objectLoader send];
}