mongoid-tree 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/mongoid/tree.rb +5 -1
- data/spec/mongoid/tree_spec.rb +5 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2efbc10260f22d9266cedf4f51ea25db0e7385e0
|
4
|
+
data.tar.gz: e07926dc9a02d5c22f8f49abd91305a94d96e3f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0328b760885d2a4442a1f4dedfcf741f6cd18f4a1902924287a06ca41fef76f7c927d8a110dfd869350fc02dc0aefde9381652d7d5f1dd25dad199c5b7b19491
|
7
|
+
data.tar.gz: 24970a25867dc1550a658f569a84c4e596d53748268ab944a8424c2367f9221537f39cb04736aaf944992af541adb7a514fe43e4daddf68b919a8430ae279ee1
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/lib/mongoid/tree.rb
CHANGED
@@ -272,7 +272,11 @@ module Mongoid
|
|
272
272
|
#
|
273
273
|
# @return [Mongoid::Criteria] Mongoid criteria to retrieve the documents ancestors
|
274
274
|
def ancestors
|
275
|
-
|
275
|
+
if parent_ids.any?
|
276
|
+
base_class.or(parent_ids.map { |id| { :_id => id } })
|
277
|
+
else
|
278
|
+
base_class.where(:_id.in => [])
|
279
|
+
end
|
276
280
|
end
|
277
281
|
|
278
282
|
##
|
data/spec/mongoid/tree_spec.rb
CHANGED
@@ -288,6 +288,11 @@ describe Mongoid::Tree do
|
|
288
288
|
|
289
289
|
expect(subchild.ancestors.to_a).to eq([child, root])
|
290
290
|
end
|
291
|
+
|
292
|
+
it 'should return nothing when there are no ancestors' do
|
293
|
+
root = Node.new(:name => 'root')
|
294
|
+
expect(root.ancestors).to be_empty
|
295
|
+
end
|
291
296
|
end
|
292
297
|
|
293
298
|
describe '#ancestors_and_self' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benedikt Deicke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -94,7 +94,8 @@ files:
|
|
94
94
|
- Gemfile
|
95
95
|
- .rspec
|
96
96
|
homepage: https://github.com/benedikt/mongoid-tree
|
97
|
-
licenses:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
98
99
|
metadata: {}
|
99
100
|
post_install_message:
|
100
101
|
rdoc_options: []
|