simple_nested_set 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,14 +16,17 @@ module SimpleNestedSet
16
16
  def perform
17
17
  if path && node.path_changed?
18
18
  node.move_to_path(path)
19
- elsif attributes.key?(:left_id) && left_id != node.id
19
+ elsif attributes.key?(:left_id) && left_id != node.id && (left_id || !parent_id)
20
20
  node.move_to_right_of(left_id)
21
- elsif attributes.key?(:right_id) && right_id != node.id
21
+ elsif attributes.key?(:right_id) && right_id != node.id && (right_id || !parent_id)
22
22
  node.move_to_left_of(right_id)
23
- end
24
-
25
- if attributes.key?(:parent_id) && parent_id != node.parent_id
23
+ elsif attributes.key?(:parent_id) && parent_id != node.parent_id
26
24
  node.move_to_child_of(parent_id)
25
+ if attributes.key?(:left_id) && left_id != node.id
26
+ node.move_to_right_of(left_id)
27
+ elsif attributes.key?(:right_id) && right_id != node.id
28
+ node.move_to_left_of(right_id)
29
+ end
27
30
  end
28
31
  end
29
32
 
@@ -1,3 +1,3 @@
1
1
  module SimpleNestedSet
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 16
10
- version: 0.0.16
9
+ - 17
10
+ version: 0.0.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs