has_siblings 0.2.7 → 0.2.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 +5 -5
- data/LICENSE.txt +21 -0
- data/README.md +4 -1
- data/has_siblings.gemspec +3 -2
- data/lib/has_siblings/class_methods.rb +5 -1
- data/lib/has_siblings/version.rb +1 -1
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 74413b0cd5fbe98208341f508142e4e8c083dd7fb7a3676c19c99e679b36672c
|
4
|
+
data.tar.gz: 2bfc9e15371ce603dc2ae124b1ab05e0c11be55f0bb1600d601f358f84255fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f14c41f5d1bb0cabc447590fc085ab330528877ab00a14093f0c13c6c97338857926de1a056fc2b05831ee695a1cd59df8b3f0d7e86a8a6acdd41d952fa2ac74
|
7
|
+
data.tar.gz: e52ab634d35ef47b1654c4c5226de60670d32d3c8f99dc3f9ab419497c7773a5053b42a552f8f88ec11182178f7070fc06ce565b86ba925876b8503ede8fa717
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Annkissam
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -69,7 +69,10 @@ An example of what it returns:
|
|
69
69
|
|
70
70
|
`has_siblings` accepts a `through: [...]` option that specifies the parents and can
|
71
71
|
be an array or a single symbol, and an optional `name` that will be the name of
|
72
|
-
the siblings method (default to `siblings`).
|
72
|
+
the siblings method (default to `siblings`). By default, when specifying an array of
|
73
|
+
parents, any `nil` association will result in an empty sibling collection, if parents
|
74
|
+
can optionally be blank setting `allow_nil: true` will include the present parents and
|
75
|
+
and the missing parent as conditions to the sibling scope.
|
73
76
|
|
74
77
|
## Compatibility
|
75
78
|
|
data/has_siblings.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{Easily define a siblings method for a child model instance.}
|
13
13
|
spec.description = %q{ parent.children.where.not(id: self.id), extended to n parents }
|
14
14
|
spec.homepage = "https://github.com/annkissam/has_siblings"
|
15
|
+
spec.license = "MIT"
|
15
16
|
|
16
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
18
|
# delete this section to allow pushing this gem to any host.
|
@@ -27,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
27
28
|
spec.require_paths = ["lib"]
|
28
29
|
|
29
30
|
spec.add_dependency "activerecord", ">= 4.0"
|
30
|
-
spec.add_development_dependency "bundler", "
|
31
|
-
spec.add_development_dependency "rake", "
|
31
|
+
spec.add_development_dependency "bundler", ">= 1.17"
|
32
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
32
33
|
spec.add_development_dependency "rspec"
|
33
34
|
spec.add_development_dependency "rspec-its"
|
34
35
|
spec.add_development_dependency "sqlite3"
|
@@ -7,6 +7,7 @@ module HasSiblings
|
|
7
7
|
def has_siblings(options = {})
|
8
8
|
*parents = options.fetch(:through)
|
9
9
|
name = options.fetch(:name, "siblings")
|
10
|
+
allow_nil = options.fetch(:allow_nil, false)
|
10
11
|
|
11
12
|
reflections = parents.map do |parent|
|
12
13
|
reflection = reflect_on_association(parent)
|
@@ -28,7 +29,10 @@ module HasSiblings
|
|
28
29
|
|
29
30
|
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
30
31
|
def #{name}
|
31
|
-
|
32
|
+
unless #{allow_nil}
|
33
|
+
return self.class.none if [#{parents.join(",")}].any?(&:nil?)
|
34
|
+
end
|
35
|
+
|
32
36
|
self.class.#{where_scopes.join(".")}.where.not(id: id)
|
33
37
|
end
|
34
38
|
CODE
|
data/lib/has_siblings/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_siblings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Octavian Neamtu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.17'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.17'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- ".travis.yml"
|
135
135
|
- Appraisals
|
136
136
|
- Gemfile
|
137
|
+
- LICENSE.txt
|
137
138
|
- README.md
|
138
139
|
- Rakefile
|
139
140
|
- bin/console
|
@@ -150,10 +151,11 @@ files:
|
|
150
151
|
- lib/has_siblings/errors.rb
|
151
152
|
- lib/has_siblings/version.rb
|
152
153
|
homepage: https://github.com/annkissam/has_siblings
|
153
|
-
licenses:
|
154
|
+
licenses:
|
155
|
+
- MIT
|
154
156
|
metadata:
|
155
157
|
allowed_push_host: https://rubygems.org
|
156
|
-
post_install_message:
|
158
|
+
post_install_message:
|
157
159
|
rdoc_options: []
|
158
160
|
require_paths:
|
159
161
|
- lib
|
@@ -168,9 +170,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
170
|
- !ruby/object:Gem::Version
|
169
171
|
version: '0'
|
170
172
|
requirements: []
|
171
|
-
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
173
|
-
signing_key:
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.7.6
|
175
|
+
signing_key:
|
174
176
|
specification_version: 4
|
175
177
|
summary: Easily define a siblings method for a child model instance.
|
176
178
|
test_files: []
|