lib/mongoid/relations/cascading/destroy.rb in mongoid-2.2.0 vs lib/mongoid/relations/cascading/destroy.rb in mongoid-2.2.1
- old
+ new
@@ -9,10 +9,17 @@
# objects from the db.
#
# @example Perform the cascading destroy.
# strategy.cascade
def cascade
- relation.to_a.each { |doc| doc.destroy } if relation
+ if relation
+ if relation.is_a?(Enumerable)
+ relation.entries
+ relation.each { |doc| doc.destroy }
+ else
+ relation.destroy
+ end
+ end
end
end
end
end
end