mongoid-tags-arent-hard 1.1.1 → 1.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.
data/README.md
CHANGED
@@ -78,6 +78,14 @@ Foo.with_all_colors("a")
|
|
78
78
|
Foo.with_all_colors(["a", "b"])
|
79
79
|
Foo.with_all_colors("a, b")
|
80
80
|
|
81
|
+
# Find objects without any of the values:
|
82
|
+
Foo.without_any_tags("a")
|
83
|
+
Foo.without_any_tags(["a", "b"])
|
84
|
+
Foo.without_any_tags("a, b")
|
85
|
+
Foo.without_any_colors("a")
|
86
|
+
Foo.without_any_colors(["a", "b"])
|
87
|
+
Foo.without_any_colors("a, b")
|
88
|
+
|
81
89
|
# Retrieve a distinct array of all tags
|
82
90
|
Foo.all_tags
|
83
91
|
Foo.where(name: 'test').all_tags
|
@@ -97,5 +105,6 @@ Again, notice that you can use either a string, an array, or a splatted list as
|
|
97
105
|
## Contributers
|
98
106
|
|
99
107
|
* Mark Bates
|
108
|
+
* Carsten Block
|
100
109
|
* Luke Bergen
|
101
|
-
*
|
110
|
+
* Laurent Arnoud
|
@@ -45,9 +45,13 @@ module Mongoid
|
|
45
45
|
self.class.send(:define_method, "with_all_#{name}") do |*val|
|
46
46
|
all_in(name => Mongoid::TagsArentHard::Tags.new(*val, {}).tag_list)
|
47
47
|
end
|
48
|
+
|
49
|
+
self.class.send(:define_method, "without_any_#{name}") do |*val|
|
50
|
+
not_in(name => Mongoid::TagsArentHard::Tags.new(*val, {}).tag_list)
|
51
|
+
end
|
48
52
|
end
|
49
53
|
|
50
54
|
end
|
51
55
|
|
52
56
|
end
|
53
|
-
end
|
57
|
+
end
|
@@ -259,8 +259,93 @@ describe Mongoid::TagsArentHard do
|
|
259
259
|
|
260
260
|
end
|
261
261
|
|
262
|
+
describe "without_any_#{_name}" do
|
263
|
+
|
264
|
+
it "returns all models without any #{_name} (splatted)" do
|
265
|
+
results = Foo.send("without_any_#{_name}", "a")
|
266
|
+
results.should_not have(1).foo
|
267
|
+
results.should_not include(@foo1)
|
268
|
+
|
269
|
+
results = Foo.send("without_any_#{_name}", "b")
|
270
|
+
results.should_not have(2).foos
|
271
|
+
results.should_not include(@foo1)
|
272
|
+
results.should_not include(@foo2)
|
273
|
+
|
274
|
+
results = Foo.send("without_any_#{_name}", "a", "e")
|
275
|
+
results.should_not have(2).foos
|
276
|
+
results.should_not include(@foo1)
|
277
|
+
results.should_not include(@foo3)
|
278
|
+
|
279
|
+
results = Foo.send("without_any_#{_name}", 'a', 'z')
|
280
|
+
results.should have(2).foos
|
281
|
+
results.should include(@foo2)
|
282
|
+
results.should include(@foo3)
|
283
|
+
|
284
|
+
results = Foo.send("without_any_#{_name}", 'z')
|
285
|
+
results.should have(3).foos
|
286
|
+
results.should include(@foo1)
|
287
|
+
results.should include(@foo2)
|
288
|
+
results.should include(@foo3)
|
289
|
+
end
|
290
|
+
|
291
|
+
it "returns all models without any #{_name} (arrayed)" do
|
292
|
+
results = Foo.send("without_any_#{_name}", ["a"])
|
293
|
+
results.should_not have(1).foo
|
294
|
+
results.should_not include(@foo1)
|
295
|
+
|
296
|
+
results = Foo.send("without_any_#{_name}", ["b"])
|
297
|
+
results.should_not have(2).foos
|
298
|
+
results.should_not include(@foo1)
|
299
|
+
results.should_not include(@foo2)
|
300
|
+
|
301
|
+
results = Foo.send("without_any_#{_name}", ["a", "e"])
|
302
|
+
results.should_not have(2).foos
|
303
|
+
results.should_not include(@foo1)
|
304
|
+
results.should_not include(@foo3)
|
305
|
+
|
306
|
+
results = Foo.send("without_any_#{_name}", ['a', 'z'])
|
307
|
+
results.should have(2).foos
|
308
|
+
results.should include(@foo2)
|
309
|
+
results.should include(@foo3)
|
310
|
+
|
311
|
+
results = Foo.send("without_any_#{_name}", ['z'])
|
312
|
+
results.should have(3).foos
|
313
|
+
results.should include(@foo1)
|
314
|
+
results.should include(@foo2)
|
315
|
+
results.should include(@foo3)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "returns all models without any #{_name} (string)" do
|
319
|
+
results = Foo.send("without_any_#{_name}", "a")
|
320
|
+
results.should_not have(1).foo
|
321
|
+
results.should_not include(@foo1)
|
322
|
+
|
323
|
+
results = Foo.send("without_any_#{_name}", "b")
|
324
|
+
results.should_not have(2).foos
|
325
|
+
results.should_not include(@foo1)
|
326
|
+
results.should_not include(@foo2)
|
327
|
+
|
328
|
+
results = Foo.send("without_any_#{_name}", "a,e")
|
329
|
+
results.should_not have(2).foos
|
330
|
+
results.should_not include(@foo1)
|
331
|
+
results.should_not include(@foo3)
|
332
|
+
|
333
|
+
results = Foo.send("without_any_#{_name}", 'a,z')
|
334
|
+
results.should have(2).foos
|
335
|
+
results.should include(@foo2)
|
336
|
+
results.should include(@foo3)
|
337
|
+
|
338
|
+
results = Foo.send("without_any_#{_name}", 'z')
|
339
|
+
results.should have(3).foos
|
340
|
+
results.should include(@foo1)
|
341
|
+
results.should include(@foo2)
|
342
|
+
results.should include(@foo3)
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
262
347
|
end
|
263
348
|
|
264
349
|
end
|
265
350
|
|
266
|
-
end
|
351
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-tags-arent-hard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.8.
|
72
|
+
rubygems_version: 1.8.25
|
73
73
|
signing_key:
|
74
74
|
specification_version: 3
|
75
75
|
summary: A tagging gem for Mongoid 3 that doesn't actually suck.
|