Permalink
Browse files

Replace 'assigneeLogin' field with 'assignee' to demo nested models

Fixes #46.
  • Loading branch information...
1 parent 3821368 commit 6d3a96e099a20a7d0e6b0af72634a23ba7624c7c @jspahrsummers jspahrsummers committed Mar 1, 2013
Showing with 11 additions and 7 deletions.
  1. +11 −7 README.md
View
@@ -34,8 +34,8 @@ typedef enum : NSUInteger {
@property (nonatomic, copy, readonly) NSNumber *number;
@property (nonatomic, assign, readonly) GHIssueState state;
@property (nonatomic, copy, readonly) NSString *reporterLogin;
-@property (nonatomic, copy, readonly) NSString *assigneeLogin;
@property (nonatomic, copy, readonly) NSDate *updatedAt;
+@property (nonatomic, strong, readonly) GHUser *assignee;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *body;
@@ -72,7 +72,7 @@ typedef enum : NSUInteger {
_title = [dictionary[@"title"] copy];
_body = [dictionary[@"body"] copy];
_reporterLogin = [dictionary[@"user"][@"login"] copy];
- _assigneeLogin = [dictionary[@"assignee"][@"login"] copy];
+ _assignee = [[GHUser alloc] initWithDictionary:dictionary[@"assignee"]];
_updatedAt = [self.class.dateFormatter dateFromString:dictionary[@"updated_at"]];
@@ -90,7 +90,7 @@ typedef enum : NSUInteger {
_title = [coder decodeObjectForKey:@"title"];
_body = [coder decodeObjectForKey:@"body"];
_reporterLogin = [coder decodeObjectForKey:@"reporterLogin"];
- _assigneeLogin = [coder decodeObjectForKey:@"assigneeLogin"];
+ _assignee = [coder decodeObjectForKey:@"assignee"];
_updatedAt = [coder decodeObjectForKey:@"updatedAt"];
return self;
@@ -103,7 +103,7 @@ typedef enum : NSUInteger {
if (self.title != nil) [coder encodeObject:self.title forKey:@"title"];
if (self.body != nil) [coder encodeObject:self.body forKey:@"body"];
if (self.reporterLogin != nil) [coder encodeObject:self.reporterLogin forKey:@"reporterLogin"];
- if (self.assigneeLogin != nil) [coder encodeObject:self.assigneeLogin forKey:@"assigneeLogin"];
+ if (self.assignee != nil) [coder encodeObject:self.assignee forKey:@"assignee"];
if (self.updatedAt != nil) [coder encodeObject:self.updatedAt forKey:@"updatedAt"];
[coder encodeUnsignedInteger:self.state forKey:@"state"];
@@ -116,7 +116,7 @@ typedef enum : NSUInteger {
issue->_number = self.number;
issue->_state = self.state;
issue->_reporterLogin = self.reporterLogin;
- issue->_assigneeLogin = self.assigneeLogin;
+ issue->_assignee = self.assignee;
issue->_updatedAt = self.updatedAt;
issue.title = self.title;
@@ -186,7 +186,7 @@ typedef enum : NSUInteger {
@property (nonatomic, copy, readonly) NSNumber *number;
@property (nonatomic, assign, readonly) GHIssueState state;
@property (nonatomic, copy, readonly) NSString *reporterLogin;
-@property (nonatomic, copy, readonly) NSString *assigneeLogin;
+@property (nonatomic, strong, readonly) GHUser *assignee;
@property (nonatomic, copy, readonly) NSDate *updatedAt;
@property (nonatomic, copy) NSString *title;
@@ -210,7 +210,7 @@ typedef enum : NSUInteger {
@"URL": @"url",
@"HTMLURL": @"html_url",
@"reporterLogin": @"user.login",
- @"assigneeLogin": @"assignee.login",
+ @"assignee": @"assignee",
@"updatedAt": @"updated_at"
};
}
@@ -236,6 +236,10 @@ typedef enum : NSUInteger {
}];
}
++ (NSValueTransformer *)assigneeJSONTransformer {
+ return [NSValueTransformer mtl_JSONDictionaryTransformerWithModelClass:GHUser.class];
+}
+
+ (NSValueTransformer *)updatedAtJSONTransformer {
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSString *str) {
return [self.dateFormatter dateFromString:str];

0 comments on commit 6d3a96e

Please sign in to comment.