motion/managed_object.rb in cdq-1.0.2 vs motion/managed_object.rb in cdq-1.0.3
- old
+ new
@@ -40,15 +40,15 @@
# query directly.
#
def scope(name, query = nil, &block)
cdq.scope(name, query, &block)
if query
- self.class.send(:define_method, name) do
+ define_method(name) do
where(query)
end
else
- self.class.send(:define_method, name) do |*args|
+ define_method(name) do |*args|
where(block.call(*args))
end
end
end
@@ -170,9 +170,18 @@
end
end
def oid
objectID.URIRepresentation.absoluteString.inspect
+ end
+
+ def method_missing(name, *args, &block)
+ if name[-1] == "?"
+ property_name = name[0...-1]
+ if entity.propertiesByName[property_name] && entity.propertiesByName[property_name].attributeType == NSBooleanAttributeType
+ send(property_name) == 1 ? true : false
+ end
+ end
end
protected
# Called from method that's dynamically added from