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
- return nil if self == parent.children.last
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
- if other == other.parent.children.last
339
- send(:encoded_path=, other.parent.send(:next_child_encoded_path))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DanaDanger-hyrarchy
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Danger