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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24949ac2737e35c6e035a25166a40c6a9f7ffbef
4
- data.tar.gz: 150ffc447cd318882b4ad9c8452141e90313edd6
3
+ metadata.gz: f1635b02e4add5bbcbc6c4bec29d746e4b366fa4
4
+ data.tar.gz: 8c4f8cc48562268d727ffaf324be0078aaff9784
5
5
  SHA512:
6
- metadata.gz: fa47c6d372289ea255ba9f82cc02e15a0c404ada0763c56396d2bbdbddf8a5b406fe2b89185d28bcb1d9167d9ee539177edc3a88a8673e4544010b926b97051c
7
- data.tar.gz: 359b80019c845f1932e65157340660829c12f3ce7f352ed686261118fd1c55f3d83ed99e43961e4218f0197d7bda46ff709f4e81d664202095663b6b38a819be
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.0
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