parentry 0.3.0 → 0.3.1
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/lib/parentry.rb +3 -1
- data/lib/parentry/instance_methods.rb +1 -1
- data/lib/parentry/navigation.rb +3 -2
- data/lib/parentry/version.rb +1 -1
- 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: 261e45f2ceb096605d761ed6a774684edc24c53a
|
4
|
+
data.tar.gz: 42d22ad8ccc1f2217b67ad6af01fff03dd85a454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c63b998524c891a393505a8464b668338f0bd9f06936884315b092a46bc962c7eaf6a28f5d0e548d569fc29c2749e4b33dee99dc30aca10567b4dbdb22f9c320
|
7
|
+
data.tar.gz: e20688b736eac361ac213242cdbd1eff5116f316ccb863de1dabdf11878f45c901357a126dcc84e8c037e3913820ef8ed9315a994c10d27c026412e576879779
|
data/lib/parentry.rb
CHANGED
@@ -23,7 +23,9 @@ module Parentry
|
|
23
23
|
after_create :commit_parentry
|
24
24
|
before_update :assign_parentry, if: proc { changes[:parent_id].present? }
|
25
25
|
after_update :cascade_parentry, if: proc { changes[parentry_column].present? }
|
26
|
-
|
26
|
+
|
27
|
+
before_validation :cache_parentry_depth, if: proc { cache_depth }
|
28
|
+
before_save :cache_parentry_depth, if: proc { cache_depth }
|
27
29
|
|
28
30
|
after_save :touch_ancestors_callback
|
29
31
|
after_touch :touch_ancestors_callback
|
data/lib/parentry/navigation.rb
CHANGED
@@ -9,7 +9,7 @@ module Parentry
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def root?
|
12
|
-
|
12
|
+
parent_id.nil?
|
13
13
|
end
|
14
14
|
|
15
15
|
def path_ids
|
@@ -78,7 +78,8 @@ module Parentry
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def depth
|
81
|
-
|
81
|
+
return depth_offset if root?
|
82
|
+
parent.depth + 1
|
82
83
|
end
|
83
84
|
|
84
85
|
private
|
data/lib/parentry/version.rb
CHANGED