voteable_mongoid 0.5.0 → 0.6.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/CHANGELOG.rdoc +19 -0
- data/lib/voteable_mongoid/version.rb +1 -1
- data/lib/voteable_mongoid/voteable/stats.rb +21 -29
- data/lib/voteable_mongoid/voteable/votes.rb +21 -0
- data/lib/voteable_mongoid/voteable.rb +44 -52
- data/lib/voteable_mongoid/voter.rb +19 -3
- data/lib/voteable_mongoid.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/voteable_mongoid/voteable_spec.rb +6 -18
- data/spec/voteable_mongoid/voter_spec.rb +8 -0
- metadata +6 -26
- data/doc/Mongoid/Voteable/Stats.html +0 -733
- data/doc/Mongoid/Voteable.html +0 -505
- data/doc/Mongoid/Voter.html +0 -682
- data/doc/Mongoid.html +0 -93
- data/doc/Rails/VoteableMongoid/Railtie.html +0 -110
- data/doc/Rails/VoteableMongoid.html +0 -101
- data/doc/Rails.html +0 -101
- data/doc/VoteableMongoid.html +0 -94
- data/doc/_index.html +0 -164
- data/doc/class_list.html +0 -36
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -53
- data/doc/css/style.css +0 -318
- data/doc/file.README.html +0 -172
- data/doc/file_list.html +0 -38
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -172
- data/doc/js/app.js +0 -203
- data/doc/js/full_list.js +0 -149
- data/doc/js/jquery.js +0 -16
- data/doc/method_list.html +0 -187
- data/doc/top-level-namespace.html +0 -88
data/doc/Mongoid/Voter.html
DELETED
@@ -1,682 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>Module: Mongoid::Voter</title>
|
7
|
-
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
-
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
-
|
10
|
-
<script type="text/javascript" charset="utf-8">
|
11
|
-
relpath = '..';
|
12
|
-
if (relpath != '') relpath += '/';
|
13
|
-
</script>
|
14
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
15
|
-
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
16
|
-
|
17
|
-
</head>
|
18
|
-
<body>
|
19
|
-
<script type="text/javascript" charset="utf-8">
|
20
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
-
</script>
|
22
|
-
|
23
|
-
<div id="header">
|
24
|
-
<div id="menu">
|
25
|
-
|
26
|
-
<a href="../_index.html">Index (V)</a> »
|
27
|
-
<span class='title'><span class='object_link'><a href="../Mongoid.html" title="Mongoid (module)">Mongoid</a></span></span>
|
28
|
-
»
|
29
|
-
<span class="title">Voter</span>
|
30
|
-
|
31
|
-
|
32
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="search">
|
36
|
-
<a id="class_list_link" href="#">Class List</a>
|
37
|
-
<a id="method_list_link" href="#">Method List</a>
|
38
|
-
<a id ="file_list_link" href="#">File List</a>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div class="clear"></div>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<iframe id="search_frame"></iframe>
|
45
|
-
|
46
|
-
<div id="content"><h1>Module: Mongoid::Voter
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
</h1>
|
51
|
-
|
52
|
-
<dl class="box">
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<dt class="r1">Extended by:</dt>
|
57
|
-
<dd class="r1">ActiveSupport::Concern</dd>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
<dt class="r2 last">Defined in:</dt>
|
66
|
-
<dd class="r2 last">lib/voteable_mongoid/voter.rb</dd>
|
67
|
-
|
68
|
-
</dl>
|
69
|
-
<div class="clear"></div>
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
<h2>
|
77
|
-
Instance Method Summary
|
78
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
79
|
-
</h2>
|
80
|
-
|
81
|
-
<ul class="summary">
|
82
|
-
|
83
|
-
<li class="public ">
|
84
|
-
<span class="summary_signature">
|
85
|
-
|
86
|
-
<a href="#unvote-instance_method" title="#unvote (instance method)">- (Object) <strong>unvote</strong>(options) </a>
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
</span>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<span class="summary_desc"><div class='inline'>
|
100
|
-
<p>Cancel the vote on a votee.</p>
|
101
|
-
</div></span>
|
102
|
-
|
103
|
-
</li>
|
104
|
-
|
105
|
-
|
106
|
-
<li class="public ">
|
107
|
-
<span class="summary_signature">
|
108
|
-
|
109
|
-
<a href="#vote-instance_method" title="#vote (instance method)">- (Object) <strong>vote</strong>(options, value = nil) </a>
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
</span>
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
<span class="summary_desc"><div class='inline'>
|
123
|
-
<p>Vote on a votee.</p>
|
124
|
-
</div></span>
|
125
|
-
|
126
|
-
</li>
|
127
|
-
|
128
|
-
|
129
|
-
<li class="public ">
|
130
|
-
<span class="summary_signature">
|
131
|
-
|
132
|
-
<a href="#vote_value-instance_method" title="#vote_value (instance method)">- (Symbol<sup>?</sup>) <strong>vote_value</strong>(options) </a>
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
</span>
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
<span class="summary_desc"><div class='inline'>
|
146
|
-
<p>Get the voted value on a votee.</p>
|
147
|
-
</div></span>
|
148
|
-
|
149
|
-
</li>
|
150
|
-
|
151
|
-
|
152
|
-
<li class="public ">
|
153
|
-
<span class="summary_signature">
|
154
|
-
|
155
|
-
<a href="#voted%3F-instance_method" title="#voted? (instance method)">- (true, false) <strong>voted?</strong>(options) </a>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
</span>
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
<span class="summary_desc"><div class='inline'>
|
169
|
-
<p>Check to see if this voter voted on the votee or not.</p>
|
170
|
-
</div></span>
|
171
|
-
|
172
|
-
</li>
|
173
|
-
|
174
|
-
|
175
|
-
<li class="public ">
|
176
|
-
<span class="summary_signature">
|
177
|
-
|
178
|
-
<a href="#votees-instance_method" title="#votees (instance method)">- (Array<sup>?</sup>) <strong>votees</strong>(klass) </a>
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
</span>
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
<span class="summary_desc"><div class='inline'>
|
192
|
-
<p>Get list of voted votees.</p>
|
193
|
-
</div></span>
|
194
|
-
|
195
|
-
</li>
|
196
|
-
|
197
|
-
|
198
|
-
</ul>
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
<div id="instance_method_details" class="method_details_list">
|
205
|
-
<h2>Instance Method Details</h2>
|
206
|
-
|
207
|
-
|
208
|
-
<div class="method_details first">
|
209
|
-
<p class="signature first" id="unvote-instance_method">
|
210
|
-
|
211
|
-
- (<tt>Object</tt>) <strong>unvote</strong>(options)
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
</p><div class="docstring">
|
216
|
-
<div class="discussion">
|
217
|
-
|
218
|
-
<p>Cancel the vote on a votee</p>
|
219
|
-
|
220
|
-
|
221
|
-
</div>
|
222
|
-
</div>
|
223
|
-
<div class="tags">
|
224
|
-
<h3>Parameters:</h3>
|
225
|
-
<ul class="param">
|
226
|
-
|
227
|
-
<li>
|
228
|
-
|
229
|
-
<span class='type'>(<tt>Object</tt>)</span>
|
230
|
-
|
231
|
-
|
232
|
-
<span class='name'>votee</span>
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
—
|
237
|
-
<div class='inline'>
|
238
|
-
<p>the votee to be unvoted</p>
|
239
|
-
</div>
|
240
|
-
|
241
|
-
</li>
|
242
|
-
|
243
|
-
</ul>
|
244
|
-
|
245
|
-
</div><table class="source_code">
|
246
|
-
<tr>
|
247
|
-
<td>
|
248
|
-
<pre class="lines">
|
249
|
-
|
250
|
-
|
251
|
-
53
|
252
|
-
54
|
253
|
-
55
|
254
|
-
56
|
255
|
-
57
|
256
|
-
58
|
257
|
-
59
|
258
|
-
60</pre>
|
259
|
-
</td>
|
260
|
-
<td>
|
261
|
-
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voter.rb', line 53</span>
|
262
|
-
|
263
|
-
<span class='def def kw'>def</span> <span class='unvote identifier id'>unvote</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
264
|
-
<span class='unless unless kw'>unless</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
265
|
-
<span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span> <span class='symbol val'>:votee</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='options identifier id'>options</span> <span class='rbrace token'>}</span>
|
266
|
-
<span class='end end kw'>end</span>
|
267
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:unvote</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='true true kw'>true</span>
|
268
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:revote</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='false false kw'>false</span>
|
269
|
-
<span class='vote identifier id'>vote</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
270
|
-
<span class='end end kw'>end</span>
|
271
|
-
</pre>
|
272
|
-
</td>
|
273
|
-
</tr>
|
274
|
-
</table>
|
275
|
-
</div>
|
276
|
-
|
277
|
-
<div class="method_details ">
|
278
|
-
<p class="signature " id="vote-instance_method">
|
279
|
-
|
280
|
-
- (<tt>Object</tt>) <strong>vote</strong>(options, value = nil)
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
</p><div class="docstring">
|
285
|
-
<div class="discussion">
|
286
|
-
|
287
|
-
<p>Vote on a votee</p>
|
288
|
-
|
289
|
-
|
290
|
-
</div>
|
291
|
-
</div>
|
292
|
-
<div class="tags">
|
293
|
-
<h3>Parameters:</h3>
|
294
|
-
<ul class="param">
|
295
|
-
|
296
|
-
<li>
|
297
|
-
|
298
|
-
<span class='type'>(<tt>:up</tt>, <tt>:down</tt>)</span>
|
299
|
-
|
300
|
-
|
301
|
-
<span class='name'>vote_value</span>
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
—
|
306
|
-
<div class='inline'>
|
307
|
-
<p>vote up or vote down, nil to unvote</p>
|
308
|
-
</div>
|
309
|
-
|
310
|
-
</li>
|
311
|
-
|
312
|
-
<li>
|
313
|
-
|
314
|
-
<span class='type'>(<tt>Hash</tt>, <tt>Object</tt>)</span>
|
315
|
-
|
316
|
-
|
317
|
-
<span class='name'>options</span>
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
—
|
322
|
-
<div class='inline'>
|
323
|
-
<p>the hash containing the votee, or the votee itself</p>
|
324
|
-
</div>
|
325
|
-
|
326
|
-
</li>
|
327
|
-
|
328
|
-
</ul>
|
329
|
-
|
330
|
-
</div><table class="source_code">
|
331
|
-
<tr>
|
332
|
-
<td>
|
333
|
-
<pre class="lines">
|
334
|
-
|
335
|
-
|
336
|
-
66
|
337
|
-
67
|
338
|
-
68
|
339
|
-
69
|
340
|
-
70
|
341
|
-
71
|
342
|
-
72
|
343
|
-
73
|
344
|
-
74
|
345
|
-
75
|
346
|
-
76
|
347
|
-
77
|
348
|
-
78
|
349
|
-
79
|
350
|
-
80
|
351
|
-
81
|
352
|
-
82
|
353
|
-
83
|
354
|
-
84
|
355
|
-
85
|
356
|
-
86
|
357
|
-
87
|
358
|
-
88
|
359
|
-
89
|
360
|
-
90
|
361
|
-
91</pre>
|
362
|
-
</td>
|
363
|
-
<td>
|
364
|
-
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voter.rb', line 66</span>
|
365
|
-
|
366
|
-
<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='comma token'>,</span> <span class='value identifier id'>value</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
|
367
|
-
<span class='if if kw'>if</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
368
|
-
<span class='votee identifier id'>votee</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee</span><span class='rbrack token'>]</span>
|
369
|
-
<span class='else else kw'>else</span>
|
370
|
-
<span class='votee identifier id'>votee</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span>
|
371
|
-
<span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span> <span class='symbol val'>:votee</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='votee identifier id'>votee</span><span class='comma token'>,</span> <span class='symbol val'>:value</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='value identifier id'>value</span> <span class='rbrace token'>}</span>
|
372
|
-
<span class='end end kw'>end</span>
|
373
|
-
|
374
|
-
<span class='if if kw'>if</span> <span class='votee identifier id'>votee</span>
|
375
|
-
<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='assign token'>=</span> <span class='votee identifier id'>votee</span><span class='dot token'>.</span><span class='_id identifier id'>_id</span>
|
376
|
-
<span class='votee_class identifier id'>votee_class</span> <span class='assign token'>=</span> <span class='votee identifier id'>votee</span><span class='dot token'>.</span><span class='class identifier id'>class</span>
|
377
|
-
<span class='else else kw'>else</span>
|
378
|
-
<span class='votee_class identifier id'>votee_class</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_type</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='classify identifier id'>classify</span><span class='dot token'>.</span><span class='constantize identifier id'>constantize</span>
|
379
|
-
<span class='end end kw'>end</span>
|
380
|
-
|
381
|
-
<span class='if if kw'>if</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:value</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
|
382
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:unvote</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='true true kw'>true</span>
|
383
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:value</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='vote_value identifier id'>vote_value</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
384
|
-
<span class='else else kw'>else</span>
|
385
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:revote</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='has_key? fid id'>has_key?</span><span class='lparen token'>(</span><span class='symbol val'>:revote</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='notop op'>!</span><span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:revote</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span> <span class='colon op'>:</span> <span class='voted? fid id'>voted?</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
386
|
-
<span class='end end kw'>end</span>
|
387
|
-
|
388
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:voter_id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='_id identifier id'>_id</span>
|
389
|
-
|
390
|
-
<span class='lparen token'>(</span> <span class='votee identifier id'>votee</span> <span class='orop op'>||</span> <span class='votee_class identifier id'>votee_class</span> <span class='rparen token'>)</span><span class='dot token'>.</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>
|
391
|
-
<span class='end end kw'>end</span>
|
392
|
-
</pre>
|
393
|
-
</td>
|
394
|
-
</tr>
|
395
|
-
</table>
|
396
|
-
</div>
|
397
|
-
|
398
|
-
<div class="method_details ">
|
399
|
-
<p class="signature " id="vote_value-instance_method">
|
400
|
-
|
401
|
-
- (<tt>Symbol</tt><sup>?</sup>) <strong>vote_value</strong>(options)
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
</p><div class="docstring">
|
406
|
-
<div class="discussion">
|
407
|
-
|
408
|
-
<p>Get the voted value on a votee</p>
|
409
|
-
|
410
|
-
|
411
|
-
</div>
|
412
|
-
</div>
|
413
|
-
<div class="tags">
|
414
|
-
<h3>Parameters:</h3>
|
415
|
-
<ul class="param">
|
416
|
-
|
417
|
-
<li>
|
418
|
-
|
419
|
-
<span class='type'>(<tt>Hash</tt>, <tt>Object</tt>)</span>
|
420
|
-
|
421
|
-
|
422
|
-
<span class='name'>options</span>
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
—
|
427
|
-
<div class='inline'>
|
428
|
-
<p>the hash containing the votee, or the votee itself</p>
|
429
|
-
</div>
|
430
|
-
|
431
|
-
</li>
|
432
|
-
|
433
|
-
</ul>
|
434
|
-
<h3>Returns:</h3>
|
435
|
-
<ul class="return">
|
436
|
-
|
437
|
-
<li>
|
438
|
-
|
439
|
-
<span class='type'>(<tt>Symbol</tt>, <tt>nil</tt>)</span>
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
—
|
445
|
-
<div class='inline'>
|
446
|
-
<p>:up or :down or nil if not voted</p>
|
447
|
-
</div>
|
448
|
-
|
449
|
-
</li>
|
450
|
-
|
451
|
-
</ul>
|
452
|
-
|
453
|
-
</div><table class="source_code">
|
454
|
-
<tr>
|
455
|
-
<td>
|
456
|
-
<pre class="lines">
|
457
|
-
|
458
|
-
|
459
|
-
39
|
460
|
-
40
|
461
|
-
41
|
462
|
-
42
|
463
|
-
43
|
464
|
-
44
|
465
|
-
45
|
466
|
-
46
|
467
|
-
47
|
468
|
-
48</pre>
|
469
|
-
</td>
|
470
|
-
<td>
|
471
|
-
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voter.rb', line 39</span>
|
472
|
-
|
473
|
-
<span class='def def kw'>def</span> <span class='vote_value identifier id'>vote_value</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
474
|
-
<span class='votee identifier id'>votee</span> <span class='assign token'>=</span> <span class='unless unless kw'>unless</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
475
|
-
<span class='options identifier id'>options</span>
|
476
|
-
<span class='else else kw'>else</span>
|
477
|
-
<span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee</span><span class='rbrack token'>]</span> <span class='orop op'>||</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_type</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='classify identifier id'>classify</span><span class='dot token'>.</span><span class='constantize identifier id'>constantize</span><span class='dot token'>.</span><span class='only identifier id'>only</span><span class='lparen token'>(</span><span class='symbol val'>:up_vote_ids</span><span class='comma token'>,</span> <span class='symbol val'>:down_vote_ids</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='where identifier id'>where</span><span class='lparen token'>(</span>
|
478
|
-
<span class='symbol val'>:_id</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_id</span><span class='rbrack token'>]</span>
|
479
|
-
<span class='rparen token'>)</span><span class='dot token'>.</span><span class='first identifier id'>first</span>
|
480
|
-
<span class='end end kw'>end</span>
|
481
|
-
<span class='votee identifier id'>votee</span><span class='dot token'>.</span><span class='vote_value identifier id'>vote_value</span><span class='lparen token'>(</span><span class='_id identifier id'>_id</span><span class='rparen token'>)</span>
|
482
|
-
<span class='end end kw'>end</span>
|
483
|
-
</pre>
|
484
|
-
</td>
|
485
|
-
</tr>
|
486
|
-
</table>
|
487
|
-
</div>
|
488
|
-
|
489
|
-
<div class="method_details ">
|
490
|
-
<p class="signature " id="voted?-instance_method">
|
491
|
-
|
492
|
-
- (<tt>true</tt>, <tt>false</tt>) <strong>voted?</strong>(options)
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
</p><div class="docstring">
|
497
|
-
<div class="discussion">
|
498
|
-
|
499
|
-
<p>Check to see if this voter voted on the votee or not</p>
|
500
|
-
|
501
|
-
|
502
|
-
</div>
|
503
|
-
</div>
|
504
|
-
<div class="tags">
|
505
|
-
<h3>Parameters:</h3>
|
506
|
-
<ul class="param">
|
507
|
-
|
508
|
-
<li>
|
509
|
-
|
510
|
-
<span class='type'>(<tt>Hash</tt>, <tt>Object</tt>)</span>
|
511
|
-
|
512
|
-
|
513
|
-
<span class='name'>options</span>
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
—
|
518
|
-
<div class='inline'>
|
519
|
-
<p>the hash containing the votee, or the votee itself</p>
|
520
|
-
</div>
|
521
|
-
|
522
|
-
</li>
|
523
|
-
|
524
|
-
</ul>
|
525
|
-
<h3>Returns:</h3>
|
526
|
-
<ul class="return">
|
527
|
-
|
528
|
-
<li>
|
529
|
-
|
530
|
-
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
—
|
536
|
-
<div class='inline'>
|
537
|
-
<p>true if voted, false otherwise</p>
|
538
|
-
</div>
|
539
|
-
|
540
|
-
</li>
|
541
|
-
|
542
|
-
</ul>
|
543
|
-
|
544
|
-
</div><table class="source_code">
|
545
|
-
<tr>
|
546
|
-
<td>
|
547
|
-
<pre class="lines">
|
548
|
-
|
549
|
-
|
550
|
-
17
|
551
|
-
18
|
552
|
-
19
|
553
|
-
20
|
554
|
-
21
|
555
|
-
22
|
556
|
-
23
|
557
|
-
24
|
558
|
-
25
|
559
|
-
26
|
560
|
-
27
|
561
|
-
28
|
562
|
-
29
|
563
|
-
30
|
564
|
-
31
|
565
|
-
32
|
566
|
-
33</pre>
|
567
|
-
</td>
|
568
|
-
<td>
|
569
|
-
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voter.rb', line 17</span>
|
570
|
-
|
571
|
-
<span class='def def kw'>def</span> <span class='voted? fid id'>voted?</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
|
572
|
-
<span class='unless unless kw'>unless</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
573
|
-
<span class='votee_class identifier id'>votee_class</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='class identifier id'>class</span>
|
574
|
-
<span class='votee_id identifier id'>votee_id</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='_id identifier id'>_id</span>
|
575
|
-
<span class='else else kw'>else</span>
|
576
|
-
<span class='votee identifier id'>votee</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee</span><span class='rbrack token'>]</span>
|
577
|
-
<span class='if if kw'>if</span> <span class='votee identifier id'>votee</span>
|
578
|
-
<span class='votee_class identifier id'>votee_class</span> <span class='assign token'>=</span> <span class='votee identifier id'>votee</span><span class='dot token'>.</span><span class='class identifier id'>class</span>
|
579
|
-
<span class='votee_id identifier id'>votee_id</span> <span class='assign token'>=</span> <span class='votee identifier id'>votee</span><span class='dot token'>.</span><span class='_id identifier id'>_id</span>
|
580
|
-
<span class='else else kw'>else</span>
|
581
|
-
<span class='votee_class identifier id'>votee_class</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_type</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='classify identifier id'>classify</span><span class='dot token'>.</span><span class='constantize identifier id'>constantize</span>
|
582
|
-
<span class='votee_id identifier id'>votee_id</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:votee_id</span><span class='rbrack token'>]</span>
|
583
|
-
<span class='end end kw'>end</span>
|
584
|
-
<span class='end end kw'>end</span>
|
585
|
-
|
586
|
-
<span class='votees identifier id'>votees</span><span class='lparen token'>(</span><span class='votee_class identifier id'>votee_class</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='where identifier id'>where</span><span class='lparen token'>(</span><span class='symbol val'>:_id</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='votee_id identifier id'>votee_id</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='count identifier id'>count</span> <span class='eq op'>==</span> <span class='integer val'>1</span>
|
587
|
-
<span class='end end kw'>end</span>
|
588
|
-
</pre>
|
589
|
-
</td>
|
590
|
-
</tr>
|
591
|
-
</table>
|
592
|
-
</div>
|
593
|
-
|
594
|
-
<div class="method_details ">
|
595
|
-
<p class="signature " id="votees-instance_method">
|
596
|
-
|
597
|
-
- (<tt>Array</tt><sup>?</sup>) <strong>votees</strong>(klass)
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
</p><div class="docstring">
|
602
|
-
<div class="discussion">
|
603
|
-
|
604
|
-
<p>Get list of voted votees</p>
|
605
|
-
|
606
|
-
|
607
|
-
</div>
|
608
|
-
</div>
|
609
|
-
<div class="tags">
|
610
|
-
<h3>Parameters:</h3>
|
611
|
-
<ul class="param">
|
612
|
-
|
613
|
-
<li>
|
614
|
-
|
615
|
-
<span class='type'>(<tt>Class</tt>)</span>
|
616
|
-
|
617
|
-
|
618
|
-
<span class='name'>klass</span>
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
—
|
623
|
-
<div class='inline'>
|
624
|
-
<p>the votee class, e.g. `Post` or `Comment`</p>
|
625
|
-
</div>
|
626
|
-
|
627
|
-
</li>
|
628
|
-
|
629
|
-
</ul>
|
630
|
-
<h3>Returns:</h3>
|
631
|
-
<ul class="return">
|
632
|
-
|
633
|
-
<li>
|
634
|
-
|
635
|
-
<span class='type'>(<tt>Array</tt>, <tt>nil</tt>)</span>
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
—
|
641
|
-
<div class='inline'>
|
642
|
-
<p>an array of voteable objects voted by this voter</p>
|
643
|
-
</div>
|
644
|
-
|
645
|
-
</li>
|
646
|
-
|
647
|
-
</ul>
|
648
|
-
|
649
|
-
</div><table class="source_code">
|
650
|
-
<tr>
|
651
|
-
<td>
|
652
|
-
<pre class="lines">
|
653
|
-
|
654
|
-
|
655
|
-
9
|
656
|
-
10
|
657
|
-
11</pre>
|
658
|
-
</td>
|
659
|
-
<td>
|
660
|
-
<pre class="code"><span class="info file"># File 'lib/voteable_mongoid/voter.rb', line 9</span>
|
661
|
-
|
662
|
-
<span class='def def kw'>def</span> <span class='votees identifier id'>votees</span><span class='lparen token'>(</span><span class='klass identifier id'>klass</span><span class='rparen token'>)</span>
|
663
|
-
<span class='klass identifier id'>klass</span><span class='dot token'>.</span><span class='any_of identifier id'>any_of</span><span class='lparen token'>(</span><span class='lbrace token'>{</span> <span class='string val'>"voteable.up_voter_ids"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='_id identifier id'>_id</span> <span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='lbrace token'>{</span> <span class='string val'>"voteable.down_voter_ids"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='_id identifier id'>_id</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
664
|
-
<span class='end end kw'>end</span>
|
665
|
-
</pre>
|
666
|
-
</td>
|
667
|
-
</tr>
|
668
|
-
</table>
|
669
|
-
</div>
|
670
|
-
|
671
|
-
</div>
|
672
|
-
|
673
|
-
</div>
|
674
|
-
|
675
|
-
<div id="footer">
|
676
|
-
Generated on Wed Mar 30 22:06:28 2011 by
|
677
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
678
|
-
0.6.5 (ruby-1.8.7).
|
679
|
-
</div>
|
680
|
-
|
681
|
-
</body>
|
682
|
-
</html>
|