motion/cdq.rb in cdq-0.1.9 vs motion/cdq.rb in cdq-0.1.10

- old
+ new

@@ -49,21 +49,25 @@ @@base_object ||= CDQObject.new case obj when Class if obj.isSubclassOfClass(NSManagedObject) + entities = NSDictionary.dictionaryWithDictionary( + @@base_object.models.current.entitiesByName) entity_description = - @@base_object.models.current.entitiesByName[obj.name] || - @@base_object.models.current.entitiesByName[obj.ancestors[1].name] + entities[obj.name] || + entities[obj.ancestors[1].name] if entity_description.nil? raise "Cannot find an entity named #{obj.name}" end CDQTargetedQuery.new(entity_description, obj) else @@base_object end when String - entity_description = @@base_object.models.current.entitiesByName[obj] + entities = NSDictionary.dictionaryWithDictionary( + @@base_object.models.current.entitiesByName) + entity_description = entities[obj] target_class = NSClassFromString(entity_description.managedObjectClassName) if entity_description.nil? raise "Cannot find an entity named #{obj}" end CDQTargetedQuery.new(entity_description, target_class)