voteable_mongoid 0.4.5 → 0.5.0
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.rdoc +15 -4
- data/TODO +0 -1
- data/doc/Mongoid.html +3 -3
- data/doc/Mongoid/Voteable.html +54 -240
- data/doc/Mongoid/Voteable/Stats.html +733 -0
- data/doc/Mongoid/Voter.html +7 -7
- data/doc/Rails.html +101 -0
- data/doc/Rails/VoteableMongoid.html +101 -0
- data/doc/Rails/VoteableMongoid/Railtie.html +110 -0
- data/doc/VoteableMongoid.html +2 -2
- data/doc/_index.html +43 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +21 -6
- data/doc/index.html +21 -6
- data/doc/method_list.html +59 -11
- data/doc/top-level-namespace.html +2 -2
- data/lib/voteable_mongoid/version.rb +1 -1
- data/lib/voteable_mongoid/voteable.rb +13 -13
- data/lib/voteable_mongoid/voteable/stats.rb +5 -4
- data/spec/models/comment.rb +2 -2
- data/spec/models/post.rb +1 -1
- data/voteable_mongoid.gemspec +1 -0
- metadata +7 -4
- data/VERSION +0 -0
data/README.rdoc
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
Voteable Mongoid allows you to make your Mongoid::Document objects voteable (up or down)
|
4
4
|
|
5
|
-
For instance, in a
|
5
|
+
For instance, in a forum, a user can vote up (or down) on a post or a comment.
|
6
6
|
|
7
7
|
When user provided enough information, voteable_mongoid will use only one update-in-place operation per collection.
|
8
8
|
|
9
|
+
Sample app at https://github.com/vinova/simple_qa
|
10
|
+
|
9
11
|
== Installation
|
10
12
|
|
11
13
|
=== Rails 3.0.x
|
@@ -27,7 +29,7 @@ post.rb
|
|
27
29
|
include Mongoid::Voteable
|
28
30
|
|
29
31
|
# set points for each vote
|
30
|
-
|
32
|
+
voteable self, :up => +1, :down => -1
|
31
33
|
|
32
34
|
references_many :comments
|
33
35
|
end
|
@@ -42,10 +44,10 @@ comment.rb
|
|
42
44
|
|
43
45
|
referenced_in :post
|
44
46
|
|
45
|
-
|
47
|
+
voteable self, :up => +1, :down => -3
|
46
48
|
|
47
49
|
# each vote on a comment can affect votes count and point of the related post as well
|
48
|
-
|
50
|
+
voteable Post, :up => +2, :down => -1
|
49
51
|
end
|
50
52
|
|
51
53
|
user.rb
|
@@ -79,6 +81,15 @@ user.rb
|
|
79
81
|
|
80
82
|
@user.unvote(@comment)
|
81
83
|
|
84
|
+
=== Re-generate counters and vote points
|
85
|
+
|
86
|
+
Rails
|
87
|
+
rake db:mongoid:voteable:remake_stats
|
88
|
+
|
89
|
+
Ruby
|
90
|
+
Mongoid::Voteable::Stats.remake
|
91
|
+
|
92
|
+
|
82
93
|
== Credits
|
83
94
|
|
84
95
|
* Alex N. - Author
|
data/TODO
CHANGED
data/doc/Mongoid.html
CHANGED
@@ -59,8 +59,8 @@
|
|
59
59
|
|
60
60
|
|
61
61
|
<dt class="r1 last">Defined in:</dt>
|
62
|
-
<dd class="r1 last">lib/
|
63
|
-
lib/
|
62
|
+
<dd class="r1 last">lib/voteable_mongoid/voter.rb<span class="defines">,<br />
|
63
|
+
lib/voteable_mongoid/voteable.rb,<br /> lib/voteable_mongoid/voteable/stats.rb</span>
|
64
64
|
</dd>
|
65
65
|
|
66
66
|
</dl>
|
@@ -84,7 +84,7 @@
|
|
84
84
|
</div>
|
85
85
|
|
86
86
|
<div id="footer">
|
87
|
-
Generated on Wed Mar 30
|
87
|
+
Generated on Wed Mar 30 22:06:28 2011 by
|
88
88
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
89
89
|
0.6.5 (ruby-1.8.7).
|
90
90
|
</div>
|
data/doc/Mongoid/Voteable.html
CHANGED
@@ -63,22 +63,34 @@
|
|
63
63
|
|
64
64
|
|
65
65
|
<dt class="r2 last">Defined in:</dt>
|
66
|
-
<dd class="r2 last">lib/
|
66
|
+
<dd class="r2 last">lib/voteable_mongoid/voteable.rb<span class="defines">,<br />
|
67
|
+
lib/voteable_mongoid/voteable/stats.rb</span>
|
68
|
+
</dd>
|
67
69
|
|
68
70
|
</dl>
|
69
71
|
<div class="clear"></div>
|
70
72
|
|
73
|
+
<h2>Defined Under Namespace</h2>
|
74
|
+
<p class="children">
|
75
|
+
|
76
|
+
|
77
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Voteable/Stats.html" title="Mongoid::Voteable::Stats (module)">Stats</a></span>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
</p>
|
71
83
|
|
72
84
|
<h2>Constant Summary</h2>
|
73
85
|
|
74
86
|
<dl class="constants">
|
75
87
|
|
76
|
-
<dt id="
|
88
|
+
<dt id="VOTEABLE-constant" class="">VOTEABLE =
|
77
89
|
<div class="docstring">
|
78
90
|
<div class="discussion">
|
79
91
|
|
80
92
|
<p>How many points should be assigned for each up or down vote. This hash
|
81
|
-
should
|
93
|
+
should manipulated using voteable method</p>
|
82
94
|
|
83
95
|
|
84
96
|
</div>
|
@@ -124,29 +136,6 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
124
136
|
<p>Array of down voter ids.</p>
|
125
137
|
</div></span>
|
126
138
|
|
127
|
-
</li>
|
128
|
-
|
129
|
-
|
130
|
-
<li class="public ">
|
131
|
-
<span class="summary_signature">
|
132
|
-
|
133
|
-
<a href="#down_votes_count-instance_method" title="#down_votes_count (instance method)">- (Object) <strong>down_votes_count</strong> </a>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
</span>
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
<span class="summary_desc"><div class='inline'>
|
147
|
-
<p>Get the number of down votes.</p>
|
148
|
-
</div></span>
|
149
|
-
|
150
139
|
</li>
|
151
140
|
|
152
141
|
|
@@ -170,29 +159,6 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
170
159
|
<p>Array of up voter ids.</p>
|
171
160
|
</div></span>
|
172
161
|
|
173
|
-
</li>
|
174
|
-
|
175
|
-
|
176
|
-
<li class="public ">
|
177
|
-
<span class="summary_signature">
|
178
|
-
|
179
|
-
<a href="#up_votes_count-instance_method" title="#up_votes_count (instance method)">- (Object) <strong>up_votes_count</strong> </a>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
</span>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
<span class="summary_desc"><div class='inline'>
|
193
|
-
<p>Get the number of up votes.</p>
|
194
|
-
</div></span>
|
195
|
-
|
196
162
|
</li>
|
197
163
|
|
198
164
|
|
@@ -245,30 +211,7 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
245
211
|
<li class="public ">
|
246
212
|
<span class="summary_signature">
|
247
213
|
|
248
|
-
<a href="#
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
</span>
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
<span class="summary_desc"><div class='inline'>
|
262
|
-
<p>Get the number of votes count.</p>
|
263
|
-
</div></span>
|
264
|
-
|
265
|
-
</li>
|
266
|
-
|
267
|
-
|
268
|
-
<li class="public ">
|
269
|
-
<span class="summary_signature">
|
270
|
-
|
271
|
-
<a href="#votes_point-instance_method" title="#votes_point (instance method)">- (Object) <strong>votes_point</strong> </a>
|
214
|
+
<a href="#voteable-instance_method" title="#voteable (instance method)">- (Object) <strong>voteable</strong> </a>
|
272
215
|
|
273
216
|
|
274
217
|
|
@@ -281,9 +224,7 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
281
224
|
|
282
225
|
|
283
226
|
|
284
|
-
<span class="summary_desc"><div class='inline'>
|
285
|
-
<p>Get the votes point.</p>
|
286
|
-
</div></span>
|
227
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
287
228
|
|
288
229
|
</li>
|
289
230
|
|
@@ -321,12 +262,12 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
321
262
|
<pre class="lines">
|
322
263
|
|
323
264
|
|
324
|
-
|
325
|
-
|
326
|
-
|
265
|
+
238
|
266
|
+
239
|
267
|
+
240</pre>
|
327
268
|
</td>
|
328
269
|
<td>
|
329
|
-
<pre class="code"><span class="info file"># File 'lib/
|
270
|
+
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voteable.rb', line 238</span>
|
330
271
|
|
331
272
|
<span class='def def kw'>def</span> <span class='down_voter_ids identifier id'>down_voter_ids</span>
|
332
273
|
<span class='voteable identifier id'>voteable</span><span class='dot token'>.</span><span class='try identifier id'>try</span><span class='lparen token'>(</span><span class='symbol val'>:[]</span><span class='comma token'>,</span> <span class='string val'>'down_voter_ids'</span><span class='rparen token'>)</span> <span class='orop op'>||</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
|
@@ -335,45 +276,6 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
335
276
|
</td>
|
336
277
|
</tr>
|
337
278
|
</table>
|
338
|
-
</div>
|
339
|
-
|
340
|
-
<div class="method_details ">
|
341
|
-
<p class="signature " id="down_votes_count-instance_method">
|
342
|
-
|
343
|
-
- (<tt>Object</tt>) <strong>down_votes_count</strong>
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
</p><div class="docstring">
|
348
|
-
<div class="discussion">
|
349
|
-
|
350
|
-
<p>Get the number of down votes</p>
|
351
|
-
|
352
|
-
|
353
|
-
</div>
|
354
|
-
</div>
|
355
|
-
<div class="tags">
|
356
|
-
|
357
|
-
</div><table class="source_code">
|
358
|
-
<tr>
|
359
|
-
<td>
|
360
|
-
<pre class="lines">
|
361
|
-
|
362
|
-
|
363
|
-
202
|
364
|
-
203
|
365
|
-
204</pre>
|
366
|
-
</td>
|
367
|
-
<td>
|
368
|
-
<pre class="code"><span class="info file"># File 'lib/mongoid/voteable.rb', line 202</span>
|
369
|
-
|
370
|
-
<span class='def def kw'>def</span> <span class='down_votes_count identifier id'>down_votes_count</span>
|
371
|
-
<span class='down_voter_ids identifier id'>down_voter_ids</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
|
372
|
-
<span class='end end kw'>end</span>
|
373
|
-
</pre>
|
374
|
-
</td>
|
375
|
-
</tr>
|
376
|
-
</table>
|
377
279
|
</div>
|
378
280
|
|
379
281
|
<div class="method_details ">
|
@@ -399,12 +301,12 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
399
301
|
<pre class="lines">
|
400
302
|
|
401
303
|
|
402
|
-
|
403
|
-
|
404
|
-
|
304
|
+
233
|
305
|
+
234
|
306
|
+
235</pre>
|
405
307
|
</td>
|
406
308
|
<td>
|
407
|
-
<pre class="code"><span class="info file"># File 'lib/
|
309
|
+
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voteable.rb', line 233</span>
|
408
310
|
|
409
311
|
<span class='def def kw'>def</span> <span class='up_voter_ids identifier id'>up_voter_ids</span>
|
410
312
|
<span class='voteable identifier id'>voteable</span><span class='dot token'>.</span><span class='try identifier id'>try</span><span class='lparen token'>(</span><span class='symbol val'>:[]</span><span class='comma token'>,</span> <span class='string val'>'up_voter_ids'</span><span class='rparen token'>)</span> <span class='orop op'>||</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
|
@@ -413,45 +315,6 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
413
315
|
</td>
|
414
316
|
</tr>
|
415
317
|
</table>
|
416
|
-
</div>
|
417
|
-
|
418
|
-
<div class="method_details ">
|
419
|
-
<p class="signature " id="up_votes_count-instance_method">
|
420
|
-
|
421
|
-
- (<tt>Object</tt>) <strong>up_votes_count</strong>
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
</p><div class="docstring">
|
426
|
-
<div class="discussion">
|
427
|
-
|
428
|
-
<p>Get the number of up votes</p>
|
429
|
-
|
430
|
-
|
431
|
-
</div>
|
432
|
-
</div>
|
433
|
-
<div class="tags">
|
434
|
-
|
435
|
-
</div><table class="source_code">
|
436
|
-
<tr>
|
437
|
-
<td>
|
438
|
-
<pre class="lines">
|
439
|
-
|
440
|
-
|
441
|
-
197
|
442
|
-
198
|
443
|
-
199</pre>
|
444
|
-
</td>
|
445
|
-
<td>
|
446
|
-
<pre class="code"><span class="info file"># File 'lib/mongoid/voteable.rb', line 197</span>
|
447
|
-
|
448
|
-
<span class='def def kw'>def</span> <span class='up_votes_count identifier id'>up_votes_count</span>
|
449
|
-
<span class='up_voter_ids identifier id'>up_voter_ids</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
|
450
|
-
<span class='end end kw'>end</span>
|
451
|
-
</pre>
|
452
|
-
</td>
|
453
|
-
</tr>
|
454
|
-
</table>
|
455
318
|
</div>
|
456
319
|
|
457
320
|
<div class="method_details ">
|
@@ -502,21 +365,21 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
502
365
|
<pre class="lines">
|
503
366
|
|
504
367
|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
368
|
+
210
|
369
|
+
211
|
370
|
+
212
|
371
|
+
213
|
372
|
+
214
|
373
|
+
215
|
374
|
+
216
|
375
|
+
217
|
376
|
+
218
|
377
|
+
219
|
378
|
+
220
|
379
|
+
221</pre>
|
517
380
|
</td>
|
518
381
|
<td>
|
519
|
-
<pre class="code"><span class="info file"># File 'lib/
|
382
|
+
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voteable.rb', line 210</span>
|
520
383
|
|
521
384
|
<span class='def def kw'>def</span> <span class='vote identifier id'>vote</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
522
385
|
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_id</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='_id identifier id'>_id</span>
|
@@ -579,14 +442,14 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
579
442
|
<pre class="lines">
|
580
443
|
|
581
444
|
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
445
|
+
226
|
446
|
+
227
|
447
|
+
228
|
448
|
+
229
|
449
|
+
230</pre>
|
587
450
|
</td>
|
588
451
|
<td>
|
589
|
-
<pre class="code"><span class="info file"># File 'lib/
|
452
|
+
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voteable.rb', line 226</span>
|
590
453
|
|
591
454
|
<span class='def def kw'>def</span> <span class='vote_value identifier id'>vote_value</span><span class='lparen token'>(</span><span class='voter identifier id'>voter</span><span class='rparen token'>)</span>
|
592
455
|
<span class='voter_id identifier id'>voter_id</span> <span class='assign token'>=</span> <span class='voter identifier id'>voter</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='BSON constant id'>BSON</span><span class='colon2 op'>::</span><span class='ObjectId constant id'>ObjectId</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='voter identifier id'>voter</span> <span class='colon op'>:</span> <span class='voter identifier id'>voter</span><span class='dot token'>.</span><span class='_id identifier id'>_id</span>
|
@@ -600,76 +463,27 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
600
463
|
</div>
|
601
464
|
|
602
465
|
<div class="method_details ">
|
603
|
-
<p class="signature " id="
|
604
|
-
|
605
|
-
- (<tt>Object</tt>) <strong>votes_count</strong>
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
</p><div class="docstring">
|
610
|
-
<div class="discussion">
|
611
|
-
|
612
|
-
<p>Get the number of votes count</p>
|
613
|
-
|
614
|
-
|
615
|
-
</div>
|
616
|
-
</div>
|
617
|
-
<div class="tags">
|
618
|
-
|
619
|
-
</div><table class="source_code">
|
620
|
-
<tr>
|
621
|
-
<td>
|
622
|
-
<pre class="lines">
|
623
|
-
|
624
|
-
|
625
|
-
207
|
626
|
-
208
|
627
|
-
209</pre>
|
628
|
-
</td>
|
629
|
-
<td>
|
630
|
-
<pre class="code"><span class="info file"># File 'lib/mongoid/voteable.rb', line 207</span>
|
631
|
-
|
632
|
-
<span class='def def kw'>def</span> <span class='votes_count identifier id'>votes_count</span>
|
633
|
-
<span class='voteable identifier id'>voteable</span><span class='dot token'>.</span><span class='try identifier id'>try</span><span class='lparen token'>(</span><span class='symbol val'>:[]</span><span class='comma token'>,</span> <span class='string val'>'votes_count'</span><span class='rparen token'>)</span> <span class='orop op'>||</span> <span class='integer val'>0</span>
|
634
|
-
<span class='end end kw'>end</span>
|
635
|
-
</pre>
|
636
|
-
</td>
|
637
|
-
</tr>
|
638
|
-
</table>
|
639
|
-
</div>
|
640
|
-
|
641
|
-
<div class="method_details ">
|
642
|
-
<p class="signature " id="votes_point-instance_method">
|
643
|
-
|
644
|
-
- (<tt>Object</tt>) <strong>votes_point</strong>
|
466
|
+
<p class="signature " id="voteable-instance_method">
|
645
467
|
|
646
|
-
|
468
|
+
- (<tt>Object</tt>) <strong>voteable</strong>
|
647
469
|
|
648
|
-
</p><div class="docstring">
|
649
|
-
<div class="discussion">
|
650
|
-
|
651
|
-
<p>Get the votes point</p>
|
652
|
-
|
653
470
|
|
654
|
-
</div>
|
655
|
-
</div>
|
656
|
-
<div class="tags">
|
657
471
|
|
658
|
-
</
|
472
|
+
</p><table class="source_code">
|
659
473
|
<tr>
|
660
474
|
<td>
|
661
475
|
<pre class="lines">
|
662
476
|
|
663
477
|
|
664
|
-
|
665
|
-
|
666
|
-
|
478
|
+
242
|
479
|
+
243
|
480
|
+
244</pre>
|
667
481
|
</td>
|
668
482
|
<td>
|
669
|
-
<pre class="code"><span class="info file"># File 'lib/
|
483
|
+
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voteable.rb', line 242</span>
|
670
484
|
|
671
|
-
<span class='def def kw'>def</span> <span class='
|
672
|
-
<span class='
|
485
|
+
<span class='def def kw'>def</span> <span class='voteable identifier id'>voteable</span>
|
486
|
+
<span class='read_attribute identifier id'>read_attribute</span><span class='lparen token'>(</span><span class='string val'>'voteable'</span><span class='rparen token'>)</span>
|
673
487
|
<span class='end end kw'>end</span>
|
674
488
|
</pre>
|
675
489
|
</td>
|
@@ -682,7 +496,7 @@ should be accessed and manipulated using Voteable.vote_point method</p>
|
|
682
496
|
</div>
|
683
497
|
|
684
498
|
<div id="footer">
|
685
|
-
Generated on Wed Mar 30
|
499
|
+
Generated on Wed Mar 30 22:06:28 2011 by
|
686
500
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
687
501
|
0.6.5 (ruby-1.8.7).
|
688
502
|
</div>
|