hierarchical_db 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/hierarchical_db.gemspec +1 -1
- data/lib/hierarchical_db.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7c6a0c377dd9cdbac0f86ffce7156ee192b729
|
4
|
+
data.tar.gz: 47656c44af51dad752cf3bed95e1b7e1ec0d0167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed4d6738d32c8a88aac196f59641d00c81ca76588e374a0d617fb62448726908a25d58595046dcde492d83731d5c3609ac21ca328aeacb7a2a941c44326d5a5
|
7
|
+
data.tar.gz: 399082663d6a8861934b149819be95e66eb557eb3c6f10c0940d94780f2117f5f01458cad4728886ef15f20249143590fde27b05b3a25bf41740da0e8e753aa3
|
data/hierarchical_db.gemspec
CHANGED
data/lib/hierarchical_db.rb
CHANGED
@@ -65,6 +65,7 @@ module HierarchicalDb extend ActiveSupport::Concern
|
|
65
65
|
#case it has descendants
|
66
66
|
unless father.nil?
|
67
67
|
last_brother = father.descendants.where(:rgt => father.descendants.maximum(:rgt))
|
68
|
+
#case has brothers
|
68
69
|
unless last_brother.empty?
|
69
70
|
last_brother = last_brother[0]
|
70
71
|
previous_right = last_brother.rgt
|
@@ -78,6 +79,9 @@ module HierarchicalDb extend ActiveSupport::Concern
|
|
78
79
|
t.rgt = t.rgt + 2
|
79
80
|
t.save
|
80
81
|
end
|
82
|
+
#case hasn't brothers
|
83
|
+
else
|
84
|
+
previous_right = father.rgt
|
81
85
|
end
|
82
86
|
#case it is root
|
83
87
|
else
|