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

- old
+ new

@@ -61,11 +61,15 @@ def method_missing(name, *args, &block) cdq.send(name, *args, &block) end def respond_to?(name) - super || cdq.respond_to?(name) + if cdq_initialized? + super(name) || cdq.respond_to?(name) + else + super(name) + end end def destroy_all self.all.array.each do |instance| instance.destroy @@ -73,9 +77,21 @@ end def destroy_all! destroy_all cdq.save + end + + def cdq(obj = nil) + if obj + super(obj) + else + @cdq_object ||= super(nil) + end + end + + def cdq_initialized? + !@cdq_object.nil? end end # Register this object for destruction with the current context. Will not