Permalink
Browse files

push

  • Loading branch information...
1 parent a7850a4 commit eea1a31c4985ac23542233c3af7e29721f9d5792 @sled committed Jul 7, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/mongoid_acts_as_tree.rb
@@ -53,18 +53,20 @@ def acts_as_tree(options = {})
# overwrite parent=
def parent_with_checking=(new_parent)
if new_parent.present?
+ # chain to original relation
+ parent_without_checking=(new_parent)
if new_parent != self.parent && new_parent.is_a?(Mongoid::Acts::Tree)
self.write_attribute parent_id_field, new_parent.id
new_parent.children.push self, false
end
else
+ # chain to original relation
+ parent_without_checking=(nil)
self.write_attribute parent_id_field, nil
self.path = []
self.depth = 0
end
-
- # chain to original relation
- parent_without_checking=(new_parent)
+
end
# use advise-around pattern to intercept mongoid relation

0 comments on commit eea1a31

Please sign in to comment.