forked from dennisreimann/ioctocat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GHRef.m
33 lines (27 loc) · 865 Bytes
/
GHRef.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#import "GHResource.h"
#import "GHRef.h"
#import "GHCommit.h"
#import "GHTag.h"
#import "GHRepository.h"
#import "NSDictionary_IOCExtensions.h"
@implementation GHRef
- (id)initWithRepo:(GHRepository *)repo andRef:(NSString *)ref {
self = [super init];
if (self) {
self.repository = repo;
self.ref = ref;
self.resourcePath = [NSString stringWithFormat:kTagFormat, self.repository.owner, self.repository.name, self.ref];
}
return self;
}
#pragma mark Loading
- (void)setValues:(id)dict {
NSString *type = [dict ioc_stringForKeyPath:@"object.type"];
NSString *sha = [dict ioc_stringForKey:@"sha"];
if ([type isEqualToString:@"commit"]) {
self.object = [[GHCommit alloc] initWithRepository:self.repository andCommitID:sha];
} else if ([type isEqualToString:@"tag"]) {
self.object = [[GHTag alloc] initWithRepo:self.repository sha:sha];
}
}
@end