corral_acl 0.9.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +7 -0
- data/corral.gemspec +17 -0
- data/doc/Ability.html +257 -0
- data/doc/Corral/Ability.html +802 -0
- data/doc/Corral/AccessDenied.html +146 -0
- data/doc/Corral/AuthorizationNotPerformed.html +145 -0
- data/doc/Corral/ControllerAdditions/ClassMethods.html +277 -0
- data/doc/Corral/ControllerAdditions.html +513 -0
- data/doc/Corral/Error.html +141 -0
- data/doc/Corral/Generators/AbilityGenerator.html +195 -0
- data/doc/Corral/Generators.html +117 -0
- data/doc/Corral/NullRule.html +226 -0
- data/doc/Corral/SubjectRule.html +406 -0
- data/doc/Corral.html +131 -0
- data/doc/_index.html +194 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +474 -0
- data/doc/doc/_index.html +87 -0
- data/doc/doc/class_list.html +51 -0
- data/doc/doc/css/common.css +1 -0
- data/doc/doc/css/full_list.css +58 -0
- data/doc/doc/css/style.css +474 -0
- data/doc/doc/file_list.html +51 -0
- data/doc/doc/frames.html +17 -0
- data/doc/doc/index.html +87 -0
- data/doc/doc/js/app.js +243 -0
- data/doc/doc/js/full_list.js +216 -0
- data/doc/doc/js/jquery.js +4 -0
- data/doc/doc/method_list.html +51 -0
- data/doc/doc/top-level-namespace.html +102 -0
- data/doc/file.README.html +82 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +82 -0
- data/doc/js/app.js +243 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +211 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/corral/ability.rb +85 -0
- data/lib/corral/controller_additions.rb +76 -0
- data/lib/corral/exceptions.rb +10 -0
- data/lib/corral/rule.rb +45 -0
- data/lib/corral/version.rb +3 -0
- data/lib/corral.rb +5 -0
- data/lib/generators/corral/ability/USAGE +4 -0
- data/lib/generators/corral/ability/ability_generator.rb +11 -0
- data/lib/generators/corral/ability/templates/ability.rb +25 -0
- data/spec/corral/ability_spec.rb +26 -0
- data/spec/spec_helper.rb +97 -0
- metadata +101 -0
@@ -0,0 +1,802 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Corral::Ability
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.0
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Corral::Ability";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (A)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Corral.html" title="Corral (module)">Corral</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Ability</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<iframe id="search_frame" src="../class_list.html"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><h1>Module: Corral::Ability
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
</h1>
|
69
|
+
<div class="box_info">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Included in:</dt>
|
81
|
+
<dd><span class='object_link'><a href="../Ability.html" title="Ability (class)">Ability</a></span></dd>
|
82
|
+
</dl>
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
<dl>
|
87
|
+
<dt>Defined in:</dt>
|
88
|
+
<dd>lib/corral/ability.rb</dd>
|
89
|
+
</dl>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<h2>
|
102
|
+
Instance Method Summary
|
103
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
104
|
+
</h2>
|
105
|
+
|
106
|
+
<ul class="summary">
|
107
|
+
|
108
|
+
<li class="public ">
|
109
|
+
<span class="summary_signature">
|
110
|
+
|
111
|
+
<a href="#allow_anything%21-instance_method" title="#allow_anything! (instance method)">#<strong>allow_anything!</strong> ⇒ Object </a>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
</span>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<span class="summary_desc"><div class='inline'>
|
126
|
+
<p>Allow the object to perform any action on any subject.</p>
|
127
|
+
</div></span>
|
128
|
+
|
129
|
+
</li>
|
130
|
+
|
131
|
+
|
132
|
+
<li class="public ">
|
133
|
+
<span class="summary_signature">
|
134
|
+
|
135
|
+
<a href="#authorize%21-instance_method" title="#authorize! (instance method)">#<strong>authorize!</strong>(action, subject, *args) ⇒ Object </a>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
</span>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
<span class="summary_desc"><div class='inline'>
|
150
|
+
<p>Check whether the object has authorization to perform the action it intends
|
151
|
+
to on the subject.</p>
|
152
|
+
</div></span>
|
153
|
+
|
154
|
+
</li>
|
155
|
+
|
156
|
+
|
157
|
+
<li class="public ">
|
158
|
+
<span class="summary_signature">
|
159
|
+
|
160
|
+
<a href="#can-instance_method" title="#can (instance method)">#<strong>can</strong>(action, subject, &block) ⇒ Object </a>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
</span>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
<span class="summary_desc"><div class='inline'>
|
175
|
+
<p>Adds a granting-access rule.</p>
|
176
|
+
</div></span>
|
177
|
+
|
178
|
+
</li>
|
179
|
+
|
180
|
+
|
181
|
+
<li class="public ">
|
182
|
+
<span class="summary_signature">
|
183
|
+
|
184
|
+
<a href="#can%3F-instance_method" title="#can? (instance method)">#<strong>can?</strong>(action, subject, *args) ⇒ Boolean </a>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
</span>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
<span class="summary_desc"><div class='inline'>
|
199
|
+
<p>Check whether the object can perform an action on a subject.</p>
|
200
|
+
</div></span>
|
201
|
+
|
202
|
+
</li>
|
203
|
+
|
204
|
+
|
205
|
+
<li class="public ">
|
206
|
+
<span class="summary_signature">
|
207
|
+
|
208
|
+
<a href="#cannot-instance_method" title="#cannot (instance method)">#<strong>cannot</strong>(action, subject, &block) ⇒ Object </a>
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
</span>
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
<span class="summary_desc"><div class='inline'>
|
223
|
+
<p>Inverse of #can.</p>
|
224
|
+
</div></span>
|
225
|
+
|
226
|
+
</li>
|
227
|
+
|
228
|
+
|
229
|
+
<li class="public ">
|
230
|
+
<span class="summary_signature">
|
231
|
+
|
232
|
+
<a href="#cannot%3F-instance_method" title="#cannot? (instance method)">#<strong>cannot?</strong>(*args) ⇒ Boolean </a>
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
</span>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
<span class="summary_desc"><div class='inline'>
|
247
|
+
<p>Inverse of #can?.</p>
|
248
|
+
</div></span>
|
249
|
+
|
250
|
+
</li>
|
251
|
+
|
252
|
+
|
253
|
+
</ul>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
<div id="instance_method_details" class="method_details_list">
|
259
|
+
<h2>Instance Method Details</h2>
|
260
|
+
|
261
|
+
|
262
|
+
<div class="method_details first">
|
263
|
+
<h3 class="signature first" id="allow_anything!-instance_method">
|
264
|
+
|
265
|
+
#<strong>allow_anything!</strong> ⇒ <tt>Object</tt>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
</h3><div class="docstring">
|
272
|
+
<div class="discussion">
|
273
|
+
|
274
|
+
<p>Allow the object to perform any action on any subject. This overrides any
|
275
|
+
#cannot rules.</p>
|
276
|
+
|
277
|
+
|
278
|
+
</div>
|
279
|
+
</div>
|
280
|
+
<div class="tags">
|
281
|
+
|
282
|
+
|
283
|
+
</div><table class="source_code">
|
284
|
+
<tr>
|
285
|
+
<td>
|
286
|
+
<pre class="lines">
|
287
|
+
|
288
|
+
|
289
|
+
44
|
290
|
+
45
|
291
|
+
46</pre>
|
292
|
+
</td>
|
293
|
+
<td>
|
294
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 44</span>
|
295
|
+
|
296
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_allow_anything!'>allow_anything!</span>
|
297
|
+
<span class='ivar'>@allow_anything</span> <span class='op'>=</span> <span class='kw'>true</span>
|
298
|
+
<span class='kw'>end</span></pre>
|
299
|
+
</td>
|
300
|
+
</tr>
|
301
|
+
</table>
|
302
|
+
</div>
|
303
|
+
|
304
|
+
<div class="method_details ">
|
305
|
+
<h3 class="signature " id="authorize!-instance_method">
|
306
|
+
|
307
|
+
#<strong>authorize!</strong>(action, subject, *args) ⇒ <tt>Object</tt>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</h3><div class="docstring">
|
314
|
+
<div class="discussion">
|
315
|
+
|
316
|
+
<p>Check whether the object has authorization to perform the action it intends
|
317
|
+
to on the subject. Raise AccessDenied if it doesn't.</p>
|
318
|
+
|
319
|
+
|
320
|
+
</div>
|
321
|
+
</div>
|
322
|
+
<div class="tags">
|
323
|
+
<p class="tag_title">Parameters:</p>
|
324
|
+
<ul class="param">
|
325
|
+
|
326
|
+
<li>
|
327
|
+
|
328
|
+
<span class='name'>action</span>
|
329
|
+
|
330
|
+
|
331
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
—
|
336
|
+
<div class='inline'>
|
337
|
+
<p>The intended action.</p>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
</li>
|
341
|
+
|
342
|
+
<li>
|
343
|
+
|
344
|
+
<span class='name'>subject</span>
|
345
|
+
|
346
|
+
|
347
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
—
|
352
|
+
<div class='inline'>
|
353
|
+
<p>The subject of the action.</p>
|
354
|
+
</div>
|
355
|
+
|
356
|
+
</li>
|
357
|
+
|
358
|
+
</ul>
|
359
|
+
|
360
|
+
<p class="tag_title">Raises:</p>
|
361
|
+
<ul class="raise">
|
362
|
+
|
363
|
+
<li>
|
364
|
+
|
365
|
+
|
366
|
+
<span class='type'>(<tt><span class='object_link'><a href="AccessDenied.html" title="Corral::AccessDenied (class)">AccessDenied</a></span></tt>)</span>
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
—
|
371
|
+
<div class='inline'>
|
372
|
+
<p>if the object does not have permission.</p>
|
373
|
+
</div>
|
374
|
+
|
375
|
+
</li>
|
376
|
+
|
377
|
+
</ul>
|
378
|
+
|
379
|
+
</div><table class="source_code">
|
380
|
+
<tr>
|
381
|
+
<td>
|
382
|
+
<pre class="lines">
|
383
|
+
|
384
|
+
|
385
|
+
55
|
386
|
+
56
|
387
|
+
57</pre>
|
388
|
+
</td>
|
389
|
+
<td>
|
390
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 55</span>
|
391
|
+
|
392
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_authorize!'>authorize!</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
393
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>AccessDenied</span> <span class='kw'>if</span> <span class='id identifier rubyid_cannot?'>cannot?</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
394
|
+
<span class='kw'>end</span></pre>
|
395
|
+
</td>
|
396
|
+
</tr>
|
397
|
+
</table>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div class="method_details ">
|
401
|
+
<h3 class="signature " id="can-instance_method">
|
402
|
+
|
403
|
+
#<strong>can</strong>(action, subject, &block) ⇒ <tt>Object</tt>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
</h3><div class="docstring">
|
410
|
+
<div class="discussion">
|
411
|
+
|
412
|
+
<p>Adds a granting-access rule.</p>
|
413
|
+
|
414
|
+
|
415
|
+
</div>
|
416
|
+
</div>
|
417
|
+
<div class="tags">
|
418
|
+
<p class="tag_title">Parameters:</p>
|
419
|
+
<ul class="param">
|
420
|
+
|
421
|
+
<li>
|
422
|
+
|
423
|
+
<span class='name'>action</span>
|
424
|
+
|
425
|
+
|
426
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
—
|
431
|
+
<div class='inline'>
|
432
|
+
<p>The action, represented as a symbol.</p>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
</li>
|
436
|
+
|
437
|
+
<li>
|
438
|
+
|
439
|
+
<span class='name'>subject</span>
|
440
|
+
|
441
|
+
|
442
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
—
|
447
|
+
<div class='inline'>
|
448
|
+
<p>The subject.</p>
|
449
|
+
</div>
|
450
|
+
|
451
|
+
</li>
|
452
|
+
|
453
|
+
<li>
|
454
|
+
|
455
|
+
<span class='name'>block</span>
|
456
|
+
|
457
|
+
|
458
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
—
|
463
|
+
<div class='inline'>
|
464
|
+
<p>Variable arguments for more granular matching.</p>
|
465
|
+
</div>
|
466
|
+
|
467
|
+
</li>
|
468
|
+
|
469
|
+
</ul>
|
470
|
+
|
471
|
+
|
472
|
+
</div><table class="source_code">
|
473
|
+
<tr>
|
474
|
+
<td>
|
475
|
+
<pre class="lines">
|
476
|
+
|
477
|
+
|
478
|
+
30
|
479
|
+
31
|
480
|
+
32</pre>
|
481
|
+
</td>
|
482
|
+
<td>
|
483
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 30</span>
|
484
|
+
|
485
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_can'>can</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
486
|
+
<span class='id identifier rubyid_rule_for'>rule_for</span><span class='lparen'>(</span><span class='id identifier rubyid_subject'>subject</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_add_grant'>add_grant</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
487
|
+
<span class='kw'>end</span></pre>
|
488
|
+
</td>
|
489
|
+
</tr>
|
490
|
+
</table>
|
491
|
+
</div>
|
492
|
+
|
493
|
+
<div class="method_details ">
|
494
|
+
<h3 class="signature " id="can?-instance_method">
|
495
|
+
|
496
|
+
|
497
|
+
<span class="overload">#<strong>can?</strong>(action, subject) ⇒ <tt>Boolean</tt> </span>
|
498
|
+
|
499
|
+
<span class="overload">#<strong>can?</strong>(action, subject, args) ⇒ <tt>Boolean</tt> </span>
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
</h3><div class="docstring">
|
507
|
+
<div class="discussion">
|
508
|
+
|
509
|
+
<p>Check whether the object can perform an action on a subject.</p>
|
510
|
+
|
511
|
+
|
512
|
+
</div>
|
513
|
+
</div>
|
514
|
+
<div class="tags">
|
515
|
+
|
516
|
+
<p class="tag_title">Overloads:</p>
|
517
|
+
<ul class="overload">
|
518
|
+
|
519
|
+
|
520
|
+
<li class="overload_item">
|
521
|
+
<span class="signature">#<strong>can?</strong>(action, subject) ⇒ <tt>Boolean</tt> </span>
|
522
|
+
<div class="docstring">
|
523
|
+
<div class="discussion">
|
524
|
+
|
525
|
+
|
526
|
+
</div>
|
527
|
+
</div>
|
528
|
+
<div class="tags">
|
529
|
+
<p class="tag_title">Parameters:</p>
|
530
|
+
<ul class="param">
|
531
|
+
|
532
|
+
<li>
|
533
|
+
|
534
|
+
<span class='name'>action</span>
|
535
|
+
|
536
|
+
|
537
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
—
|
542
|
+
<div class='inline'>
|
543
|
+
<p>The action, represented as a symbol.</p>
|
544
|
+
</div>
|
545
|
+
|
546
|
+
</li>
|
547
|
+
|
548
|
+
<li>
|
549
|
+
|
550
|
+
<span class='name'>subject</span>
|
551
|
+
|
552
|
+
|
553
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
—
|
558
|
+
<div class='inline'>
|
559
|
+
<p>The subject.</p>
|
560
|
+
</div>
|
561
|
+
|
562
|
+
</li>
|
563
|
+
|
564
|
+
</ul>
|
565
|
+
|
566
|
+
|
567
|
+
</div>
|
568
|
+
</li>
|
569
|
+
|
570
|
+
|
571
|
+
<li class="overload_item">
|
572
|
+
<span class="signature">#<strong>can?</strong>(action, subject, args) ⇒ <tt>Boolean</tt> </span>
|
573
|
+
<div class="docstring">
|
574
|
+
<div class="discussion">
|
575
|
+
|
576
|
+
|
577
|
+
</div>
|
578
|
+
</div>
|
579
|
+
<div class="tags">
|
580
|
+
<p class="tag_title">Parameters:</p>
|
581
|
+
<ul class="param">
|
582
|
+
|
583
|
+
<li>
|
584
|
+
|
585
|
+
<span class='name'>action</span>
|
586
|
+
|
587
|
+
|
588
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
—
|
593
|
+
<div class='inline'>
|
594
|
+
<p>The action, represented as a symbol.</p>
|
595
|
+
</div>
|
596
|
+
|
597
|
+
</li>
|
598
|
+
|
599
|
+
<li>
|
600
|
+
|
601
|
+
<span class='name'>subject</span>
|
602
|
+
|
603
|
+
|
604
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
—
|
609
|
+
<div class='inline'>
|
610
|
+
<p>The subject.</p>
|
611
|
+
</div>
|
612
|
+
|
613
|
+
</li>
|
614
|
+
|
615
|
+
<li>
|
616
|
+
|
617
|
+
<span class='name'>args</span>
|
618
|
+
|
619
|
+
|
620
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
—
|
625
|
+
<div class='inline'>
|
626
|
+
<p>Variable arguments for more granular matching.</p>
|
627
|
+
</div>
|
628
|
+
|
629
|
+
</li>
|
630
|
+
|
631
|
+
</ul>
|
632
|
+
|
633
|
+
|
634
|
+
</div>
|
635
|
+
</li>
|
636
|
+
|
637
|
+
</ul>
|
638
|
+
|
639
|
+
<p class="tag_title">Returns:</p>
|
640
|
+
<ul class="return">
|
641
|
+
|
642
|
+
<li>
|
643
|
+
|
644
|
+
|
645
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
—
|
650
|
+
<div class='inline'>
|
651
|
+
<p>True or false.</p>
|
652
|
+
</div>
|
653
|
+
|
654
|
+
</li>
|
655
|
+
|
656
|
+
</ul>
|
657
|
+
|
658
|
+
</div><table class="source_code">
|
659
|
+
<tr>
|
660
|
+
<td>
|
661
|
+
<pre class="lines">
|
662
|
+
|
663
|
+
|
664
|
+
13
|
665
|
+
14
|
666
|
+
15
|
667
|
+
16</pre>
|
668
|
+
</td>
|
669
|
+
<td>
|
670
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 13</span>
|
671
|
+
|
672
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_can?'>can?</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
673
|
+
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@allow_anything</span>
|
674
|
+
<span class='id identifier rubyid_lookup_rule'>lookup_rule</span><span class='lparen'>(</span><span class='id identifier rubyid_subject'>subject</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_authorized?'>authorized?</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
675
|
+
<span class='kw'>end</span></pre>
|
676
|
+
</td>
|
677
|
+
</tr>
|
678
|
+
</table>
|
679
|
+
</div>
|
680
|
+
|
681
|
+
<div class="method_details ">
|
682
|
+
<h3 class="signature " id="cannot-instance_method">
|
683
|
+
|
684
|
+
#<strong>cannot</strong>(action, subject, &block) ⇒ <tt>Object</tt>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
</h3><div class="docstring">
|
691
|
+
<div class="discussion">
|
692
|
+
|
693
|
+
<p>Inverse of #can.</p>
|
694
|
+
|
695
|
+
|
696
|
+
</div>
|
697
|
+
</div>
|
698
|
+
<div class="tags">
|
699
|
+
|
700
|
+
|
701
|
+
<p class="tag_title">See Also:</p>
|
702
|
+
<ul class="see">
|
703
|
+
|
704
|
+
<li><span class='object_link'><a href="#can-instance_method" title="Corral::Ability#can (method)">#can</a></span></li>
|
705
|
+
|
706
|
+
</ul>
|
707
|
+
|
708
|
+
</div><table class="source_code">
|
709
|
+
<tr>
|
710
|
+
<td>
|
711
|
+
<pre class="lines">
|
712
|
+
|
713
|
+
|
714
|
+
37
|
715
|
+
38
|
716
|
+
39</pre>
|
717
|
+
</td>
|
718
|
+
<td>
|
719
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 37</span>
|
720
|
+
|
721
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cannot'>cannot</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_subject'>subject</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
722
|
+
<span class='id identifier rubyid_rule_for'>rule_for</span><span class='lparen'>(</span><span class='id identifier rubyid_subject'>subject</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_add_deny'>add_deny</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
723
|
+
<span class='kw'>end</span></pre>
|
724
|
+
</td>
|
725
|
+
</tr>
|
726
|
+
</table>
|
727
|
+
</div>
|
728
|
+
|
729
|
+
<div class="method_details ">
|
730
|
+
<h3 class="signature " id="cannot?-instance_method">
|
731
|
+
|
732
|
+
#<strong>cannot?</strong>(*args) ⇒ <tt>Boolean</tt>
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
|
738
|
+
</h3><div class="docstring">
|
739
|
+
<div class="discussion">
|
740
|
+
|
741
|
+
<p>Inverse of #can?.</p>
|
742
|
+
|
743
|
+
|
744
|
+
</div>
|
745
|
+
</div>
|
746
|
+
<div class="tags">
|
747
|
+
|
748
|
+
<p class="tag_title">Returns:</p>
|
749
|
+
<ul class="return">
|
750
|
+
|
751
|
+
<li>
|
752
|
+
|
753
|
+
|
754
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
</li>
|
759
|
+
|
760
|
+
</ul>
|
761
|
+
|
762
|
+
<p class="tag_title">See Also:</p>
|
763
|
+
<ul class="see">
|
764
|
+
|
765
|
+
<li><span class='object_link'><a href="#can%3F-instance_method" title="Corral::Ability#can? (method)">#can?</a></span></li>
|
766
|
+
|
767
|
+
</ul>
|
768
|
+
|
769
|
+
</div><table class="source_code">
|
770
|
+
<tr>
|
771
|
+
<td>
|
772
|
+
<pre class="lines">
|
773
|
+
|
774
|
+
|
775
|
+
21
|
776
|
+
22
|
777
|
+
23</pre>
|
778
|
+
</td>
|
779
|
+
<td>
|
780
|
+
<pre class="code"><span class="info file"># File 'lib/corral/ability.rb', line 21</span>
|
781
|
+
|
782
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cannot?'>cannot?</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
783
|
+
<span class='kw'>not</span> <span class='id identifier rubyid_can?'>can?</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
784
|
+
<span class='kw'>end</span></pre>
|
785
|
+
</td>
|
786
|
+
</tr>
|
787
|
+
</table>
|
788
|
+
</div>
|
789
|
+
|
790
|
+
</div>
|
791
|
+
|
792
|
+
</div>
|
793
|
+
|
794
|
+
<div id="footer">
|
795
|
+
Generated on Wed Jul 6 11:31:38 2016 by
|
796
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
797
|
+
0.9.0 (ruby-2.3.1).
|
798
|
+
</div>
|
799
|
+
|
800
|
+
</div>
|
801
|
+
</body>
|
802
|
+
</html>
|