-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCPPropertyDescription+LOExtendedProperty.j
More file actions
45 lines (29 loc) · 1.03 KB
/
Copy pathCPPropertyDescription+LOExtendedProperty.j
File metadata and controls
45 lines (29 loc) · 1.03 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Created by Martin Carlberg on February 23, 2016.
* Copyright 2016, Martin Carlberg All rights reserved.
*/
@import <Foundation/CPString.j>
@import <LightObject/CPRelationshipDescription.j>
@protocol LOExtendedAttribute
- (CPString)columnName;
@end
@protocol LOExtendedRelationship
- (CPString)foreignKeyAttributeName;
@end
@implementation CPRelationshipDescription (LOExtendedRelationship) <LOExtendedRelationship>
- (CPString)foreignKeyAttributeName {
// foreignKey name can be stored in the userInfo.
var userInfo = [self userInfo];
var foreignKeyName = [userInfo objectForKey:@"foreignKey"];
if (foreignKeyName === nil) {
// If no userInfo information exists on the relationship just assume it ends with 'ForeignKey'
foreignKeyName = [self name] + @"ForeignKey";
}
return foreignKeyName;
}
@end
@implementation CPAttributeDescription (LOExtendedAttribute) <LOExtendedAttribute>
- (CPString)columnName {
return [[self userInfo] valueForKey:@"columnName"] || [self name];
}
@end