DanaDanger-hyrarchy 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -276,7 +276,8 @@ module Hyrarchy
|
|
276
276
|
# Returns the sibling after this node. If this node is its parent's last
|
277
277
|
# child, returns nil.
|
278
278
|
def right_sibling
|
279
|
-
|
279
|
+
siblings = root? ? self.class.roots : other.parent.children
|
280
|
+
return nil if self == siblings.last
|
280
281
|
sibling_path = send(:encoded_path).next_sibling
|
281
282
|
until self.class.exists?(:lft_numer => sibling_path.numerator, :lft_denom => sibling_path.denominator)
|
282
283
|
sibling_path = sibling_path.next_sibling
|
@@ -335,8 +336,9 @@ module Hyrarchy
|
|
335
336
|
end
|
336
337
|
# If +other+ is its parent's last child, we can simply append this node
|
337
338
|
# to the parent's children.
|
338
|
-
|
339
|
-
|
339
|
+
siblings = other.root? ? self.class.roots : other.parent.children
|
340
|
+
if other == siblings.last
|
341
|
+
send(:encoded_path=, other.send(:encoded_path).next_sibling)
|
340
342
|
save!
|
341
343
|
else
|
342
344
|
# Otherwise, this is equivalent to moving this node to the left of
|