Skip to content
This repository was archived by the owner on Mar 1, 2020. It is now read-only.

Commit 06c2317

Browse files
committed
Remove module name from class
1 parent aabe05d commit 06c2317

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

bin/querykit.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extension NSAttributeDescription {
5555
extension NSRelationshipDescription {
5656
var qkAttributeDescription:AttributeDescription? {
5757
if let destinationEntity = destinationEntity {
58-
var type = destinationEntity.managedObjectClassName
58+
var type = destinationEntity.qk_className
5959

6060
if toMany {
6161
type = "Set<\(type)>"
@@ -72,6 +72,17 @@ extension NSRelationshipDescription {
7272
}
7373
}
7474

75+
extension NSEntityDescription {
76+
var qk_className:String {
77+
if managedObjectClassName.hasPrefix(".") {
78+
// "Current Module"
79+
return managedObjectClassName.substringFromIndex(managedObjectClassName.startIndex.successor())
80+
}
81+
82+
return managedObjectClassName
83+
}
84+
}
85+
7586
class CommandError : ErrorType {
7687
let description:String
7788

@@ -92,7 +103,7 @@ func render(entity:NSEntityDescription, destination:Path, template:Template) thr
92103
}
93104

94105
let context = Context(dictionary: [
95-
"className": entity.managedObjectClassName,
106+
"className": entity.qk_className,
96107
"attributes": attributes,
97108
"entityName": entity.name ?? "Unknown",
98109
])
@@ -117,7 +128,7 @@ func render(model:NSManagedObjectModel, destination:Path, templatePath:Path) {
117128

118129
for entity in model.entities {
119130
let template = try! Template(path: templatePath)!
120-
let className = entity.managedObjectClassName
131+
let className = entity.qk_className
121132

122133
if className == "NSManagedObject" {
123134
let name = entity.name ?? "Unknown"

0 commit comments

Comments
 (0)