ancestry_direct_children 0.1.0 → 0.1.2
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/ancestry_direct_children.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1635b02e4add5bbcbc6c4bec29d746e4b366fa4
|
|
4
|
+
data.tar.gz: 8c4f8cc48562268d727ffaf324be0078aaff9784
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3e27e47c8117477df56e46221c0cb898fbe9a9bd7f6a2e0c74f35b9e33d846bec64a9de7492f5a368a77210bd744fe3dd2b9f34d37bbbd1934e91790edd2b03
|
|
7
|
+
data.tar.gz: 840b883db16ae97819bf899430121a45e84602d17183c57106ce0291a9c89f3a11689ad8dff41cb510073e7324cf7a2d95b1938fb379b7e8c7aa51b33a02f355
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'ancestry'
|
|
2
|
+
|
|
3
|
+
Ancestry::InstanceMethods.module_eval do
|
|
4
|
+
def sibling_count
|
|
5
|
+
return (self.parent.direct_children_count - 1)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def update_parent_children_count!
|
|
9
|
+
unless self.parent.nil?
|
|
10
|
+
self.parent.direct_children_count = self.parent.child.count(:id)
|
|
11
|
+
self.parent.save!
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def update_parent_children_count
|
|
16
|
+
unless self.parent.nil?
|
|
17
|
+
self.parent.update_column(:direct_children_count, self.parent.child.count(:id))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ancestry_direct_children
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- A. Felipe Cabargas
|
|
@@ -15,7 +15,8 @@ email: felipe@ipsumapp.co
|
|
|
15
15
|
executables: []
|
|
16
16
|
extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
|
18
|
-
files:
|
|
18
|
+
files:
|
|
19
|
+
- lib/ancestry_direct_children.rb
|
|
19
20
|
homepage: https://rubygems.org/gems/ancestry_direct_children
|
|
20
21
|
licenses:
|
|
21
22
|
- MIT
|