Is currently WIP!
- Really declarative style!
- Handle remote object really easily.
- Handle CoreData store easily.
- Built-in validators.
- Callbacks.
You can declare the resource URL mapping.
+ (NSString *)resourceBasePath {
return @"/albums";
}
+ (NSDictionary *)resourceMap {
return @{
@(AQMRequestTypeShow): @[@(AQMRequestMethodGET), @"/:id"],
@(AQMRequestTypeCreate): @[@(AQMRequestMethodPOST), @"/"],
@(AQMRequestTypeUpdate): @[@(AQMRequestMethodPATCH), @"/:id"],
@(AQMRequestTypeDestroy): @[@(AQMRequestMethodDELETE), @"/:id"]
};
}
Then you can
[Album fetch:@"3"]; // fetches the album.
[album push]; // pushes the change of the instance.
You can store data into CoreData easily.
+ (instancetype)create;
- (BOOL)update;
- (BOOL)destroy;
+ (NSDictionary *)validationMap {
return @{
@"title": @[[AQMValidator presence], [AQMValidator shorterThan:10], [AQMValidator longerThan:3]]
};
}
Then
album.title = nil
[album validate]; // => NO
album.title = @"Hawaii";
[album validate]; // => YES
album.title = @"LongLongLongLong Title";
[album validate]; // => NO
There are some built-in validators. (Or you can add your own.)
+ (id<AQMValueValidator>)presence;
+ (id<AQMValueValidator>)longerThan:(NSUInteger)length;
+ (id<AQMValueValidator>)shorterThan:(NSUInteger)length;
+ (id<AQMValueValidator>)regexp:(NSRegularExpression *)regexp;
+ (id<AQMValueValidator>)anyOf:(NSArray *)array;
+ (id<AQMValueValidator>)email;
+ (id<AQMValueValidator>)URL;
+ (id<AQMValueValidator>)telephone;
Just implement - (BOOL)validate:(id)value
to bring your own validator.
These methods are called for each timing.
- (void)afterCreate;
- (void)beforeValidation;
- (void)afterValidation;
- (void)beforeSave;
- (void)afterSave;
As AquaModel inherits MTLModel, you can serialize them into / from JSON Dictionary.
[album dictionaryRepresentation]; // obtain JSON Dictionary
[Album modelWithDictionary:dictionary];
You should implement following class method.
+ (NSDictionary *)JSONKeyPathsByPropertyKey;
Like this,
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"URL": @"url",
@"HTMLURL": @"html_url",
@"assignee": @"assignee",
@"updatedAt": @"updated_at"
};
}
// Album.m
# pragma mark - Requestable
+ (NSString *)resourceBasePath {
return @"/albums";
}
+ (NSDictionary *)resourceMap {
return @{
@(AQMRequestTypeShow): @[@(AQMRequestMethodGET), @"/:id"],
@(AQMRequestTypeCreate): @[@(AQMRequestMethodPOST), @"/"],
@(AQMRequestTypeUpdate): @[@(AQMRequestMethodPATCH), @"/:id"],
@(AQMRequestTypeDestroy): @[@(AQMRequestMethodDELETE), @"/:id"]
};
}
# pragma mark - Validatable
+ (NSDictionary *)validationMap {
return @{
@"title": @[[AQMValidator presence], [AQMValidator shorterThan:10], [AQMValidator longerThan:3]]
};
}
# pragma mark - Serializable
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"title": @"title"
};
}
- Scope and Querying.
- List fetching and support paging.
- Handle image property (over HTTP) better.
- Better remote / local database integration. (And request caching.)
- Realm
- https://github.com/QueryKit/QueryKit
- MagicalRecord
- ObjectiveRecord
- Mantle