motion/cdq/targeted_query.rb in cdq-0.1.8 vs motion/cdq/targeted_query.rb in cdq-0.1.9

- old
+ new

@@ -81,12 +81,12 @@ # Iterate over each entity matched by the query. You can also use any method from the # Enumerable module in the standard library that does not depend on ordering. # # Causes execution. # - def each(&block) - array.each(&block) + def each(*args, &block) + array.each(*args, &block) end # Returns the fully-contstructed fetch request, which can be executed outside of CDQ. # def fetch_request @@ -157,64 +157,33 @@ out = "\n\n ATTRIBUTES" out << " \n Name | type | default |" line = " \n- - - - - - - - - - - | - - - - - - - - - - | - - - - - - - - - - - - - - - |" out << line - abn = entity_description.attributesByName - rbn = entity_description.relationshipsByName - - abn.each do |name, desc| + entity_description.attributesByName.each do |name, desc| out << " \n #{name.ljust(21)}|" out << " #{desc.attributeValueClassName.ljust(20)}|" out << " #{desc.defaultValue.to_s.ljust(30)}|" end out << line out << "\n\n" self.each do |o| - out << "OID: " - out << oid(o) - out << "\n" - - awidth = abn.keys.map(&:length).max - rwidth = rbn.keys.map(&:length).max - width = [awidth, rwidth].max - - abn.each do |name, desc| - out << " #{name.ljust(width)} : " - out << o.send(name).inspect[0,95 - width] - out << "\n" - end - rbn.each do |name, desc| - rel = CDQRelationshipQuery.new(o, name) - if desc.isToMany - out << " #{name.ljust(width)} : " - out << rel.count.to_s - out << ' (count)' - else - out << " #{name.ljust(width)} : " - out << oid(rel.first) - end - out << "\n" - end - out << "\n" + out << o.log(:string) end if log_type == :string out else NSLog out end - - rescue Exception => e - p e end private def oid(obj) - obj ? obj.objectID.URIRepresentation.absoluteString.inspect : "nil" + obj ? obj.oid : "nil" end def named_scopes @@named_scopes ||= {} @@named_scopes[@entity_description] ||= {}