corral_acl 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +22 -0
  6. data/README.md +7 -0
  7. data/corral.gemspec +17 -0
  8. data/doc/Ability.html +257 -0
  9. data/doc/Corral/Ability.html +802 -0
  10. data/doc/Corral/AccessDenied.html +146 -0
  11. data/doc/Corral/AuthorizationNotPerformed.html +145 -0
  12. data/doc/Corral/ControllerAdditions/ClassMethods.html +277 -0
  13. data/doc/Corral/ControllerAdditions.html +513 -0
  14. data/doc/Corral/Error.html +141 -0
  15. data/doc/Corral/Generators/AbilityGenerator.html +195 -0
  16. data/doc/Corral/Generators.html +117 -0
  17. data/doc/Corral/NullRule.html +226 -0
  18. data/doc/Corral/SubjectRule.html +406 -0
  19. data/doc/Corral.html +131 -0
  20. data/doc/_index.html +194 -0
  21. data/doc/class_list.html +51 -0
  22. data/doc/css/common.css +1 -0
  23. data/doc/css/full_list.css +58 -0
  24. data/doc/css/style.css +474 -0
  25. data/doc/doc/_index.html +87 -0
  26. data/doc/doc/class_list.html +51 -0
  27. data/doc/doc/css/common.css +1 -0
  28. data/doc/doc/css/full_list.css +58 -0
  29. data/doc/doc/css/style.css +474 -0
  30. data/doc/doc/file_list.html +51 -0
  31. data/doc/doc/frames.html +17 -0
  32. data/doc/doc/index.html +87 -0
  33. data/doc/doc/js/app.js +243 -0
  34. data/doc/doc/js/full_list.js +216 -0
  35. data/doc/doc/js/jquery.js +4 -0
  36. data/doc/doc/method_list.html +51 -0
  37. data/doc/doc/top-level-namespace.html +102 -0
  38. data/doc/file.README.html +82 -0
  39. data/doc/file_list.html +56 -0
  40. data/doc/frames.html +17 -0
  41. data/doc/index.html +82 -0
  42. data/doc/js/app.js +243 -0
  43. data/doc/js/full_list.js +216 -0
  44. data/doc/js/jquery.js +4 -0
  45. data/doc/method_list.html +211 -0
  46. data/doc/top-level-namespace.html +114 -0
  47. data/lib/corral/ability.rb +85 -0
  48. data/lib/corral/controller_additions.rb +76 -0
  49. data/lib/corral/exceptions.rb +10 -0
  50. data/lib/corral/rule.rb +45 -0
  51. data/lib/corral/version.rb +3 -0
  52. data/lib/corral.rb +5 -0
  53. data/lib/generators/corral/ability/USAGE +4 -0
  54. data/lib/generators/corral/ability/ability_generator.rb +11 -0
  55. data/lib/generators/corral/ability/templates/ability.rb +25 -0
  56. data/spec/corral/ability_spec.rb +26 -0
  57. data/spec/spec_helper.rb +97 -0
  58. metadata +101 -0
@@ -0,0 +1,513 @@
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::ControllerAdditions
8
+
9
+ &mdash; 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::ControllerAdditions";
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 (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Corral.html" title="Corral (module)">Corral</a></span></span>
41
+ &raquo;
42
+ <span class="title">ControllerAdditions</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::ControllerAdditions
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dl>
82
+ <dt>Defined in:</dt>
83
+ <dd>lib/corral/controller_additions.rb</dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Defined Under Namespace</h2>
89
+ <p class="children">
90
+
91
+
92
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="ControllerAdditions/ClassMethods.html" title="Corral::ControllerAdditions::ClassMethods (module)">ClassMethods</a></span>
93
+
94
+
95
+
96
+
97
+ </p>
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ <h2>
107
+ Class Method Summary
108
+ <small><a href="#" class="summary_toggle">collapse</a></small>
109
+ </h2>
110
+
111
+ <ul class="summary">
112
+
113
+ <li class="public ">
114
+ <span class="summary_signature">
115
+
116
+ <a href="#included-class_method" title="included (class method)">.<strong>included</strong>(base) &#x21d2; Object </a>
117
+
118
+
119
+
120
+ </span>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <span class="summary_desc"><div class='inline'></div></span>
131
+
132
+ </li>
133
+
134
+
135
+ </ul>
136
+
137
+ <h2>
138
+ Instance Method Summary
139
+ <small><a href="#" class="summary_toggle">collapse</a></small>
140
+ </h2>
141
+
142
+ <ul class="summary">
143
+
144
+ <li class="public ">
145
+ <span class="summary_signature">
146
+
147
+ <a href="#authorize%21-instance_method" title="#authorize! (instance method)">#<strong>authorize!</strong>(*args) &#x21d2; Object </a>
148
+
149
+
150
+
151
+ </span>
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <span class="summary_desc"><div class='inline'>
162
+ <p>Raises a Corral::AccessDenied exception if the current_ability cannot
163
+ perform the given action.</p>
164
+ </div></span>
165
+
166
+ </li>
167
+
168
+
169
+ <li class="public ">
170
+ <span class="summary_signature">
171
+
172
+ <a href="#can%3F-instance_method" title="#can? (instance method)">#<strong>can?</strong>(*args) &#x21d2; Boolean </a>
173
+
174
+
175
+
176
+ </span>
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+ <span class="summary_desc"><div class='inline'>
187
+ <p>Use in the controller or view to check the user&#39;s permission for a
188
+ given action and object.</p>
189
+ </div></span>
190
+
191
+ </li>
192
+
193
+
194
+ <li class="public ">
195
+ <span class="summary_signature">
196
+
197
+ <a href="#cannot%3F-instance_method" title="#cannot? (instance method)">#<strong>cannot?</strong>(*args) &#x21d2; Boolean </a>
198
+
199
+
200
+
201
+ </span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'>
212
+ <p>Convenience method which works the same as “can?” but returns the opposite
213
+ value.</p>
214
+ </div></span>
215
+
216
+ </li>
217
+
218
+
219
+ <li class="public ">
220
+ <span class="summary_signature">
221
+
222
+ <a href="#current_ability-instance_method" title="#current_ability (instance method)">#<strong>current_ability</strong> &#x21d2; Object </a>
223
+
224
+
225
+
226
+ </span>
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ <span class="summary_desc"><div class='inline'>
237
+ <p>Creates and returns the current user&#39;s ability and caches it.</p>
238
+ </div></span>
239
+
240
+ </li>
241
+
242
+
243
+ </ul>
244
+
245
+
246
+
247
+
248
+ <div id="class_method_details" class="method_details_list">
249
+ <h2>Class Method Details</h2>
250
+
251
+
252
+ <div class="method_details first">
253
+ <h3 class="signature first" id="included-class_method">
254
+
255
+ .<strong>included</strong>(base) &#x21d2; <tt>Object</tt>
256
+
257
+
258
+
259
+
260
+
261
+ </h3><table class="source_code">
262
+ <tr>
263
+ <td>
264
+ <pre class="lines">
265
+
266
+
267
+ 25
268
+ 26
269
+ 27
270
+ 28</pre>
271
+ </td>
272
+ <td>
273
+ <pre class="code"><span class="info file"># File 'lib/corral/controller_additions.rb', line 25</span>
274
+
275
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
276
+ <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'>ClassMethods</span>
277
+ <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_helper_method'>helper_method</span> <span class='symbol'>:can?</span><span class='comma'>,</span> <span class='symbol'>:cannot?</span><span class='comma'>,</span> <span class='symbol'>:current_ability</span> <span class='kw'>if</span> <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='symbol'>:helper_method</span>
278
+ <span class='kw'>end</span></pre>
279
+ </td>
280
+ </tr>
281
+ </table>
282
+ </div>
283
+
284
+ </div>
285
+
286
+ <div id="instance_method_details" class="method_details_list">
287
+ <h2>Instance Method Details</h2>
288
+
289
+
290
+ <div class="method_details first">
291
+ <h3 class="signature first" id="authorize!-instance_method">
292
+
293
+ #<strong>authorize!</strong>(*args) &#x21d2; <tt>Object</tt>
294
+
295
+
296
+
297
+
298
+
299
+ </h3><div class="docstring">
300
+ <div class="discussion">
301
+
302
+ <p>Raises a Corral::AccessDenied exception if the current_ability cannot
303
+ perform the given action. This is usually called in a controller action or
304
+ before filter to perform the authorization.</p>
305
+
306
+ <p>A :message option can be passed to specify a different message.</p>
307
+
308
+ <p>You can rescue from the exception in the controller to customize how
309
+ unauthorized access is displayed to the user.</p>
310
+
311
+ <p>See the load_and_authorize_resource method to automatically add the
312
+ authorize! behavior to the default RESTful actions.</p>
313
+
314
+
315
+ </div>
316
+ </div>
317
+ <div class="tags">
318
+
319
+
320
+ </div><table class="source_code">
321
+ <tr>
322
+ <td>
323
+ <pre class="lines">
324
+
325
+
326
+ 41
327
+ 42
328
+ 43
329
+ 44</pre>
330
+ </td>
331
+ <td>
332
+ <pre class="code"><span class="info file"># File 'lib/corral/controller_additions.rb', line 41</span>
333
+
334
+ <span class='kw'>def</span> <span class='id identifier rubyid_authorize!'>authorize!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
335
+ <span class='ivar'>@_authorized</span> <span class='op'>=</span> <span class='kw'>true</span>
336
+ <span class='id identifier rubyid_current_ability'>current_ability</span><span class='period'>.</span><span class='id identifier rubyid_authorize!'>authorize!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
337
+ <span class='kw'>end</span></pre>
338
+ </td>
339
+ </tr>
340
+ </table>
341
+ </div>
342
+
343
+ <div class="method_details ">
344
+ <h3 class="signature " id="can?-instance_method">
345
+
346
+ #<strong>can?</strong>(*args) &#x21d2; <tt>Boolean</tt>
347
+
348
+
349
+
350
+
351
+
352
+ </h3><div class="docstring">
353
+ <div class="discussion">
354
+
355
+ <p>Use in the controller or view to check the user&#39;s permission for a
356
+ given action and object.</p>
357
+
358
+ <p>This simply calls “can?” on the current_ability. See Ability#can?.</p>
359
+
360
+
361
+ </div>
362
+ </div>
363
+ <div class="tags">
364
+
365
+ <p class="tag_title">Returns:</p>
366
+ <ul class="return">
367
+
368
+ <li>
369
+
370
+
371
+ <span class='type'>(<tt>Boolean</tt>)</span>
372
+
373
+
374
+
375
+ </li>
376
+
377
+ </ul>
378
+
379
+ </div><table class="source_code">
380
+ <tr>
381
+ <td>
382
+ <pre class="lines">
383
+
384
+
385
+ 60
386
+ 61
387
+ 62</pre>
388
+ </td>
389
+ <td>
390
+ <pre class="code"><span class="info file"># File 'lib/corral/controller_additions.rb', line 60</span>
391
+
392
+ <span class='kw'>def</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>
393
+ <span class='id identifier rubyid_current_ability'>current_ability</span><span class='period'>.</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>
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="cannot?-instance_method">
402
+
403
+ #<strong>cannot?</strong>(*args) &#x21d2; <tt>Boolean</tt>
404
+
405
+
406
+
407
+
408
+
409
+ </h3><div class="docstring">
410
+ <div class="discussion">
411
+
412
+ <p>Convenience method which works the same as “can?” but returns the opposite
413
+ value.</p>
414
+
415
+
416
+ </div>
417
+ </div>
418
+ <div class="tags">
419
+
420
+ <p class="tag_title">Returns:</p>
421
+ <ul class="return">
422
+
423
+ <li>
424
+
425
+
426
+ <span class='type'>(<tt>Boolean</tt>)</span>
427
+
428
+
429
+
430
+ </li>
431
+
432
+ </ul>
433
+
434
+ </div><table class="source_code">
435
+ <tr>
436
+ <td>
437
+ <pre class="lines">
438
+
439
+
440
+ 66
441
+ 67
442
+ 68</pre>
443
+ </td>
444
+ <td>
445
+ <pre class="code"><span class="info file"># File 'lib/corral/controller_additions.rb', line 66</span>
446
+
447
+ <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>
448
+ <span class='id identifier rubyid_current_ability'>current_ability</span><span class='period'>.</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>
449
+ <span class='kw'>end</span></pre>
450
+ </td>
451
+ </tr>
452
+ </table>
453
+ </div>
454
+
455
+ <div class="method_details ">
456
+ <h3 class="signature " id="current_ability-instance_method">
457
+
458
+ #<strong>current_ability</strong> &#x21d2; <tt>Object</tt>
459
+
460
+
461
+
462
+
463
+
464
+ </h3><div class="docstring">
465
+ <div class="discussion">
466
+
467
+ <p>Creates and returns the current user&#39;s ability and caches it. If you
468
+ want to override how the Ability is defined then this is the place. Just
469
+ define the method in the controller to change behavior.</p>
470
+
471
+ <p>Notice it is important to memoize the ability object so it is not recreated
472
+ every time.</p>
473
+
474
+
475
+ </div>
476
+ </div>
477
+ <div class="tags">
478
+
479
+
480
+ </div><table class="source_code">
481
+ <tr>
482
+ <td>
483
+ <pre class="lines">
484
+
485
+
486
+ 52
487
+ 53
488
+ 54</pre>
489
+ </td>
490
+ <td>
491
+ <pre class="code"><span class="info file"># File 'lib/corral/controller_additions.rb', line 52</span>
492
+
493
+ <span class='kw'>def</span> <span class='id identifier rubyid_current_ability'>current_ability</span>
494
+ <span class='ivar'>@current_ability</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Ability</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_current_user'>current_user</span><span class='rparen'>)</span>
495
+ <span class='kw'>end</span></pre>
496
+ </td>
497
+ </tr>
498
+ </table>
499
+ </div>
500
+
501
+ </div>
502
+
503
+ </div>
504
+
505
+ <div id="footer">
506
+ Generated on Wed Jul 6 11:31:38 2016 by
507
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
508
+ 0.9.0 (ruby-2.3.1).
509
+ </div>
510
+
511
+ </div>
512
+ </body>
513
+ </html>
@@ -0,0 +1,141 @@
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
+ Exception: Corral::Error
8
+
9
+ &mdash; 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::Error";
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 (E)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Corral.html" title="Corral (module)">Corral</a></span></span>
41
+ &raquo;
42
+ <span class="title">Error</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>Exception: Corral::Error
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+ <dl>
72
+ <dt>Inherits:</dt>
73
+ <dd>
74
+ <span class="inheritName">StandardError</span>
75
+
76
+ <ul class="fullTree">
77
+ <li>Object</li>
78
+
79
+ <li class="next">StandardError</li>
80
+
81
+ <li class="next">Corral::Error</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <dl>
100
+ <dt>Defined in:</dt>
101
+ <dd>lib/corral/exceptions.rb</dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+
109
+ <p>A general exception</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div><div id="subclasses">
118
+ <h2>Direct Known Subclasses</h2>
119
+ <p class="children"><span class='object_link'><a href="AccessDenied.html" title="Corral::AccessDenied (class)">AccessDenied</a></span>, <span class='object_link'><a href="AuthorizationNotPerformed.html" title="Corral::AuthorizationNotPerformed (class)">AuthorizationNotPerformed</a></span></p>
120
+ </div>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ </div>
132
+
133
+ <div id="footer">
134
+ Generated on Wed Jul 6 11:31:38 2016 by
135
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
136
+ 0.9.0 (ruby-2.3.1).
137
+ </div>
138
+
139
+ </div>
140
+ </body>
141
+ </html>