compony 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/Gemfile.lock +3 -3
  4. data/README.md +1397 -33
  5. data/Rakefile +6 -2
  6. data/TODO.md +1 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/compony_controller.rb +3 -1
  9. data/compony.gemspec +7 -7
  10. data/config/locales/fr.yml +33 -0
  11. data/doc/ComponentGenerator.html +231 -0
  12. data/doc/Components.html +105 -0
  13. data/doc/ComponentsGenerator.html +203 -0
  14. data/doc/Compony/Component.html +2098 -0
  15. data/doc/Compony/ComponentMixins/Default/Labelling.html +406 -0
  16. data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +539 -0
  17. data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +588 -0
  18. data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +577 -0
  19. data/doc/Compony/ComponentMixins/Default/Standalone.html +692 -0
  20. data/doc/Compony/ComponentMixins/Default.html +126 -0
  21. data/doc/Compony/ComponentMixins/Resourceful.html +1193 -0
  22. data/doc/Compony/ComponentMixins.html +126 -0
  23. data/doc/Compony/Components/Button.html +293 -0
  24. data/doc/Compony/Components/Destroy.html +384 -0
  25. data/doc/Compony/Components/Edit.html +462 -0
  26. data/doc/Compony/Components/Form.html +1112 -0
  27. data/doc/Compony/Components/New.html +462 -0
  28. data/doc/Compony/Components/WithForm.html +528 -0
  29. data/doc/Compony/Components.html +126 -0
  30. data/doc/Compony/ControllerMixin.html +136 -0
  31. data/doc/Compony/Engine.html +133 -0
  32. data/doc/Compony/MethodAccessibleHash.html +453 -0
  33. data/doc/Compony/ModelFields/Anchormodel.html +383 -0
  34. data/doc/Compony/ModelFields/Association.html +613 -0
  35. data/doc/Compony/ModelFields/Attachment.html +305 -0
  36. data/doc/Compony/ModelFields/Base.html +1066 -0
  37. data/doc/Compony/ModelFields/Boolean.html +232 -0
  38. data/doc/Compony/ModelFields/Color.html +299 -0
  39. data/doc/Compony/ModelFields/Currency.html +232 -0
  40. data/doc/Compony/ModelFields/Date.html +232 -0
  41. data/doc/Compony/ModelFields/Datetime.html +232 -0
  42. data/doc/Compony/ModelFields/Decimal.html +154 -0
  43. data/doc/Compony/ModelFields/Email.html +240 -0
  44. data/doc/Compony/ModelFields/Float.html +154 -0
  45. data/doc/Compony/ModelFields/Integer.html +154 -0
  46. data/doc/Compony/ModelFields/Percentage.html +232 -0
  47. data/doc/Compony/ModelFields/Phone.html +301 -0
  48. data/doc/Compony/ModelFields/RichText.html +232 -0
  49. data/doc/Compony/ModelFields/String.html +154 -0
  50. data/doc/Compony/ModelFields/Text.html +154 -0
  51. data/doc/Compony/ModelFields/Time.html +154 -0
  52. data/doc/Compony/ModelFields/Url.html +240 -0
  53. data/doc/Compony/ModelFields.html +126 -0
  54. data/doc/Compony/ModelMixin.html +524 -0
  55. data/doc/Compony/RequestContext.html +791 -0
  56. data/doc/Compony/Version.html +139 -0
  57. data/doc/Compony/ViewHelpers.html +443 -0
  58. data/doc/Compony.html +2156 -0
  59. data/doc/ComponyController.html +124 -0
  60. data/doc/_index.html +569 -0
  61. data/doc/class_list.html +51 -0
  62. data/doc/css/common.css +1 -0
  63. data/doc/css/full_list.css +58 -0
  64. data/doc/css/style.css +497 -0
  65. data/doc/file.README.html +1565 -0
  66. data/doc/file_list.html +56 -0
  67. data/doc/frames.html +17 -0
  68. data/doc/imgs/intro-example-destroy.png +0 -0
  69. data/doc/imgs/intro-example-edit.png +0 -0
  70. data/doc/imgs/intro-example-index.png +0 -0
  71. data/doc/imgs/intro-example-new.png +0 -0
  72. data/doc/imgs/intro-example-show.png +0 -0
  73. data/doc/index.html +1565 -0
  74. data/doc/js/app.js +314 -0
  75. data/doc/js/full_list.js +216 -0
  76. data/doc/js/jquery.js +4 -0
  77. data/doc/method_list.html +1435 -0
  78. data/doc/resourceful_lifecycle.png +0 -0
  79. data/doc/top-level-namespace.html +112 -0
  80. data/lib/compony/component.rb +2 -1
  81. data/lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb +1 -1
  82. data/lib/compony/component_mixins/default/standalone/standalone_dsl.rb +14 -3
  83. data/lib/compony/component_mixins/default/standalone/verb_dsl.rb +14 -5
  84. data/lib/compony/component_mixins/default/standalone.rb +10 -3
  85. data/lib/compony/components/form.rb +6 -1
  86. data/lib/compony/components/with_form.rb +14 -1
  87. data/lib/compony/model_fields/anchormodel.rb +0 -22
  88. data/lib/compony/model_mixin.rb +12 -2
  89. data/lib/compony/version.rb +1 -7
  90. data/logo.svg +133 -0
  91. metadata +83 -6
@@ -0,0 +1,692 @@
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: Compony::ComponentMixins::Default::Standalone
8
+
9
+ &mdash; Documentation by YARD 0.9.34
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Compony::ComponentMixins::Default::Standalone";
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?1"></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 (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Compony.html" title="Compony (module)">Compony</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../ComponentMixins.html" title="Compony::ComponentMixins (module)">ComponentMixins</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Default.html" title="Compony::ComponentMixins::Default (module)">Default</a></span></span>
41
+ &raquo;
42
+ <span class="title">Standalone</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
+ <div id="content"><h1>Module: Compony::ComponentMixins::Default::Standalone
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+ <dl>
73
+ <dt>Extended by:</dt>
74
+ <dd>ActiveSupport::Concern</dd>
75
+ </dl>
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/compony/component_mixins/default/standalone.rb<span class="defines">,<br />
87
+ lib/compony/component_mixins/default/standalone/verb_dsl.rb,<br /> lib/compony/component_mixins/default/standalone/standalone_dsl.rb,<br /> lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb</span>
88
+ </dd>
89
+ </dl>
90
+
91
+ </div>
92
+
93
+ <h2>Overview</h2><div class="docstring">
94
+ <div class="discussion">
95
+
96
+ <p>This contains all default component logic concerning standalone functionality. The module is included in every component.</p>
97
+
98
+
99
+ </div>
100
+ </div>
101
+ <div class="tags">
102
+
103
+
104
+ </div><h2>Defined Under Namespace</h2>
105
+ <p class="children">
106
+
107
+
108
+
109
+
110
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Standalone/ResourcefulVerbDsl.html" title="Compony::ComponentMixins::Default::Standalone::ResourcefulVerbDsl (class)">ResourcefulVerbDsl</a></span>, <span class='object_link'><a href="Standalone/StandaloneDsl.html" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl (class)">StandaloneDsl</a></span>, <span class='object_link'><a href="Standalone/VerbDsl.html" title="Compony::ComponentMixins::Default::Standalone::VerbDsl (class)">VerbDsl</a></span>
111
+
112
+
113
+ </p>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <h2>
123
+ Instance Method Summary
124
+ <small><a href="#" class="summary_toggle">collapse</a></small>
125
+ </h2>
126
+
127
+ <ul class="summary">
128
+
129
+ <li class="protected ">
130
+ <span class="summary_signature">
131
+
132
+ <a href="#clear_standalone!-instance_method" title="#clear_standalone! (instance method)">#<strong>clear_standalone!</strong> &#x21d2; Object </a>
133
+
134
+
135
+
136
+ </span>
137
+
138
+
139
+
140
+ <span class="note title protected">protected</span>
141
+
142
+
143
+
144
+
145
+
146
+ <span class="summary_desc"><div class='inline'>
147
+ <p>Undoes previous standalone calls.</p>
148
+ </div></span>
149
+
150
+ </li>
151
+
152
+
153
+ <li class="public ">
154
+ <span class="summary_signature">
155
+
156
+ <a href="#on_standalone_access-instance_method" title="#on_standalone_access (instance method)">#<strong>on_standalone_access</strong>(verb_config, controller) &#x21d2; Object </a>
157
+
158
+
159
+
160
+ </span>
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'>
171
+ <p>Called by compony_controller when a request is issued.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ <li class="public ">
178
+ <span class="summary_signature">
179
+
180
+ <a href="#render_standalone-instance_method" title="#render_standalone (instance method)">#<strong>render_standalone</strong>(controller, status: nil, standalone_name: nil) &#x21d2; Object </a>
181
+
182
+
183
+
184
+ </span>
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <span class="summary_desc"><div class='inline'>
195
+ <p>Renders the component using the controller passed to it upon instanciation (calls the controller’s render) Do not overwrite.</p>
196
+ </div></span>
197
+
198
+ </li>
199
+
200
+
201
+ <li class="protected ">
202
+ <span class="summary_signature">
203
+
204
+ <a href="#standalone-instance_method" title="#standalone (instance method)">#<strong>standalone</strong>(name = nil, *args, **nargs, &amp;block) &#x21d2; Object </a>
205
+
206
+
207
+
208
+ </span>
209
+
210
+
211
+
212
+ <span class="note title protected">protected</span>
213
+
214
+
215
+
216
+
217
+
218
+ <span class="summary_desc"><div class='inline'>
219
+ <p>DSL method This can be called multiple times to make a component listen to multiple paths.</p>
220
+ </div></span>
221
+
222
+ </li>
223
+
224
+
225
+ <li class="public ">
226
+ <span class="summary_signature">
227
+
228
+ <a href="#standalone_access_permitted_for%3F-instance_method" title="#standalone_access_permitted_for? (instance method)">#<strong>standalone_access_permitted_for?</strong>(controller, standalone_name: nil, verb: nil) &#x21d2; Boolean </a>
229
+
230
+
231
+
232
+ </span>
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+ <span class="summary_desc"><div class='inline'>
243
+ <p>Call this on a standalone component to find out whether default GET access is permitted for the current user.</p>
244
+ </div></span>
245
+
246
+ </li>
247
+
248
+
249
+ </ul>
250
+
251
+
252
+
253
+
254
+
255
+ <div id="instance_method_details" class="method_details_list">
256
+ <h2>Instance Method Details</h2>
257
+
258
+
259
+ <div class="method_details first">
260
+ <h3 class="signature first" id="clear_standalone!-instance_method">
261
+
262
+ #<strong>clear_standalone!</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
263
+
264
+
265
+
266
+
267
+
268
+ </h3><div class="docstring">
269
+ <div class="discussion">
270
+
271
+ <p>Undoes previous standalone calls</p>
272
+
273
+
274
+ </div>
275
+ </div>
276
+ <div class="tags">
277
+
278
+
279
+ </div><table class="source_code">
280
+ <tr>
281
+ <td>
282
+ <pre class="lines">
283
+
284
+
285
+ 122
286
+ 123
287
+ 124</pre>
288
+ </td>
289
+ <td>
290
+ <pre class="code"><span class="info file"># File 'lib/compony/component_mixins/default/standalone.rb', line 122</span>
291
+
292
+ <span class='kw'>def</span> <span class='id identifier rubyid_clear_standalone!'>clear_standalone!</span>
293
+ <span class='ivar'>@standalone_configs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
294
+ <span class='kw'>end</span></pre>
295
+ </td>
296
+ </tr>
297
+ </table>
298
+ </div>
299
+
300
+ <div class="method_details ">
301
+ <h3 class="signature " id="on_standalone_access-instance_method">
302
+
303
+ #<strong>on_standalone_access</strong>(verb_config, controller) &#x21d2; <tt>Object</tt>
304
+
305
+
306
+
307
+
308
+
309
+ </h3><div class="docstring">
310
+ <div class="discussion">
311
+
312
+ <p>Called by compony_controller when a request is issued. This is the entrypoint where a request enters the Component world.</p>
313
+
314
+
315
+ </div>
316
+ </div>
317
+ <div class="tags">
318
+ <p class="tag_title">Parameters:</p>
319
+ <ul class="param">
320
+
321
+ <li>
322
+
323
+ <span class='name'>verb_config</span>
324
+
325
+
326
+ <span class='type'>(<tt>Hash</tt>)</span>
327
+
328
+
329
+
330
+ &mdash;
331
+ <div class='inline'>
332
+ <p>The config generated by Compony::ComponentMixins::Default::Standalone::VerbDsl#to_conf</p>
333
+ </div>
334
+
335
+ </li>
336
+
337
+ <li>
338
+
339
+ <span class='name'>controller</span>
340
+
341
+
342
+ <span class='type'>(<tt><span class='object_link'><a href="../../../ComponyController.html" title="ComponyController (class)">ComponyController</a></span></tt>)</span>
343
+
344
+
345
+
346
+ &mdash;
347
+ <div class='inline'>
348
+ <p>The controller instance that calls this method.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ </ul>
354
+
355
+
356
+ <p class="tag_title">See Also:</p>
357
+ <ul class="see">
358
+
359
+ <li><span class='object_link'><a href="../../../ComponyController.html" title="ComponyController (class)">ComponyController</a></span></li>
360
+
361
+ </ul>
362
+
363
+ </div><table class="source_code">
364
+ <tr>
365
+ <td>
366
+ <pre class="lines">
367
+
368
+
369
+ 21
370
+ 22
371
+ 23
372
+ 24
373
+ 25
374
+ 26
375
+ 27
376
+ 28
377
+ 29
378
+ 30
379
+ 31
380
+ 32
381
+ 33
382
+ 34
383
+ 35
384
+ 36
385
+ 37
386
+ 38
387
+ 39
388
+ 40
389
+ 41
390
+ 42
391
+ 43
392
+ 44
393
+ 45
394
+ 46
395
+ 47
396
+ 48
397
+ 49
398
+ 50
399
+ 51
400
+ 52
401
+ 53
402
+ 54
403
+ 55
404
+ 56
405
+ 57
406
+ 58
407
+ 59
408
+ 60
409
+ 61
410
+ 62
411
+ 63
412
+ 64
413
+ 65
414
+ 66
415
+ 67
416
+ 68
417
+ 69
418
+ 70</pre>
419
+ </td>
420
+ <td>
421
+ <pre class="code"><span class="info file"># File 'lib/compony/component_mixins/default/standalone.rb', line 21</span>
422
+
423
+ <span class='kw'>def</span> <span class='id identifier rubyid_on_standalone_access'>on_standalone_access</span><span class='lparen'>(</span><span class='id identifier rubyid_verb_config'>verb_config</span><span class='comma'>,</span> <span class='id identifier rubyid_controller'>controller</span><span class='rparen'>)</span>
424
+ <span class='comment'># Register as root comp
425
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_parent_comp'>parent_comp</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
426
+ <span class='id identifier rubyid_fail'>fail</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> is attempting to become root component, but </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_root_comp'>root_comp</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> is already root.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../../../Compony.html" title="Compony (module)">Compony</a></span></span><span class='period'>.</span><span class='id identifier rubyid_root_comp'><span class='object_link'><a href="../../../Compony.html#root_comp-class_method" title="Compony.root_comp (method)">root_comp</a></span></span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
427
+ <span class='const'>RequestStore</span><span class='period'>.</span><span class='id identifier rubyid_store'>store</span><span class='lbracket'>[</span><span class='symbol'>:compony_root_comp</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span>
428
+ <span class='kw'>end</span>
429
+
430
+ <span class='comment'># Prepare the request context in which the innermost DSL calls will be executed
431
+ </span> <span class='id identifier rubyid_request_context'>request_context</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../RequestContext.html" title="Compony::RequestContext (class)">RequestContext</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../../RequestContext.html#initialize-instance_method" title="Compony::RequestContext#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_controller'>controller</span><span class='rparen'>)</span>
432
+
433
+ <span class='comment'>###===---
434
+ </span> <span class='comment'># Dispatch request to component. Empty Dslblend base objects are used to provide multiple contexts to the authorize and respond blocks.
435
+ </span> <span class='comment'># Lifecycle is (see also &quot;doc/Resourceful Lifecycle.pdf&quot;):
436
+ </span> <span class='comment'># - load data (optional, speficied ResourcefulVerbDsl, by convention, should default to the implementation in Resourceful)
437
+ </span> <span class='comment'># - after_load_data (optional, specified in Resourceful)
438
+ </span> <span class='comment'># - assign_attributes (optional, speficied ResourcefulVerbDsl, by convention, should default to the implementation in Resourceful)
439
+ </span> <span class='comment'># - after_assign_attributes (optional, specified in Resourceful)
440
+ </span> <span class='comment'># - authorize
441
+ </span> <span class='comment'># - store_data (optional, speficied ResourcefulVerbDsl, by convention, should default to the implementation in Resourceful)
442
+ </span> <span class='comment'># - respond (typically either redirect or render standalone, specified in VerbDsl), which defaults to render_standalone, performing:
443
+ </span> <span class='comment'># - before_render
444
+ </span> <span class='comment'># - render (unless before_render already redirected)
445
+ </span> <span class='comment'>###===---
446
+ </span>
447
+ <span class='kw'>if</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_load_data_block'>load_data_block</span>
448
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_with_backfire'>evaluate_with_backfire</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_load_data_block'>load_data_block</span><span class='rparen'>)</span>
449
+ <span class='kw'>if</span> <span class='id identifier rubyid_global_after_load_data_block'>global_after_load_data_block</span>
450
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_with_backfire'>evaluate_with_backfire</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_global_after_load_data_block'>global_after_load_data_block</span><span class='rparen'>)</span>
451
+ <span class='kw'>end</span>
452
+ <span class='kw'>end</span>
453
+
454
+ <span class='kw'>if</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_assign_attributes_block'>assign_attributes_block</span>
455
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_with_backfire'>evaluate_with_backfire</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_assign_attributes_block'>assign_attributes_block</span><span class='rparen'>)</span>
456
+ <span class='kw'>if</span> <span class='id identifier rubyid_global_after_assign_attributes_block'>global_after_assign_attributes_block</span>
457
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_with_backfire'>evaluate_with_backfire</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_global_after_assign_attributes_block'>global_after_assign_attributes_block</span><span class='rparen'>)</span>
458
+ <span class='kw'>end</span>
459
+ <span class='kw'>end</span>
460
+
461
+ <span class='comment'># TODO: Make much prettier, providing message, action, subject and conditions
462
+ </span> <span class='id identifier rubyid_fail'>fail</span> <span class='const'>CanCan</span><span class='op'>::</span><span class='const'>AccessDenied</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_inspect'>inspect</span><span class='comma'>,</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_authorize_block'>authorize_block</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>, </span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_authorize_block'>authorize_block</span><span class='rparen'>)</span>
463
+
464
+ <span class='kw'>if</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_store_data_block'>store_data_block</span>
465
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate_with_backfire'>evaluate_with_backfire</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_store_data_block'>store_data_block</span><span class='rparen'>)</span>
466
+ <span class='kw'>end</span>
467
+
468
+ <span class='comment'># Check if there is a specific respond block for the format.
469
+ </span> <span class='comment'># If there isn&#39;t, fallback to the nil respond block, which defaults to `render_standalone`.
470
+ </span> <span class='id identifier rubyid_respond_block'>respond_block</span> <span class='op'>=</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_respond_blocks'>respond_blocks</span><span class='lbracket'>[</span><span class='id identifier rubyid_controller'>controller</span><span class='period'>.</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='period'>.</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_verb_config'>verb_config</span><span class='period'>.</span><span class='id identifier rubyid_respond_blocks'>respond_blocks</span><span class='lbracket'>[</span><span class='kw'>nil</span><span class='rbracket'>]</span>
471
+ <span class='id identifier rubyid_request_context'>request_context</span><span class='period'>.</span><span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_respond_block'>respond_block</span><span class='rparen'>)</span>
472
+ <span class='kw'>end</span></pre>
473
+ </td>
474
+ </tr>
475
+ </table>
476
+ </div>
477
+
478
+ <div class="method_details ">
479
+ <h3 class="signature " id="render_standalone-instance_method">
480
+
481
+ #<strong>render_standalone</strong>(controller, status: nil, standalone_name: nil) &#x21d2; <tt>Object</tt>
482
+
483
+
484
+
485
+
486
+
487
+ </h3><div class="docstring">
488
+ <div class="discussion">
489
+
490
+ <p>Renders the component using the controller passed to it upon instanciation (calls the controller’s render) Do not overwrite</p>
491
+
492
+
493
+ </div>
494
+ </div>
495
+ <div class="tags">
496
+
497
+
498
+ </div><table class="source_code">
499
+ <tr>
500
+ <td>
501
+ <pre class="lines">
502
+
503
+
504
+ 89
505
+ 90
506
+ 91
507
+ 92
508
+ 93
509
+ 94
510
+ 95
511
+ 96
512
+ 97
513
+ 98
514
+ 99
515
+ 100
516
+ 101
517
+ 102</pre>
518
+ </td>
519
+ <td>
520
+ <pre class="code"><span class="info file"># File 'lib/compony/component_mixins/default/standalone.rb', line 89</span>
521
+
522
+ <span class='kw'>def</span> <span class='id identifier rubyid_render_standalone'>render_standalone</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='label'>status:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>standalone_name:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
523
+ <span class='comment'># Start the render process. This produces a nil value if before_render has already produced a response, e.g. a redirect.
524
+ </span> <span class='id identifier rubyid_rendered_html'>rendered_html</span> <span class='op'>=</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='label'>standalone:</span> <span class='kw'>true</span><span class='rparen'>)</span>
525
+ <span class='kw'>if</span> <span class='id identifier rubyid_rendered_html'>rendered_html</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='comment'># If nil, a response body was already produced in the controller and we take no action here (would have DoubleRenderError)
526
+ </span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>html:</span> <span class='id identifier rubyid_rendered_html'>rendered_html</span><span class='comma'>,</span> <span class='label'>layout:</span> <span class='ivar'>@standalone_configs</span><span class='lbracket'>[</span><span class='id identifier rubyid_standalone_name'>standalone_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_layout'>layout</span> <span class='rbrace'>}</span>
527
+ <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:status</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_status'>status</span> <span class='kw'>if</span> <span class='id identifier rubyid_status'>status</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
528
+ <span class='id identifier rubyid_controller'>controller</span><span class='period'>.</span><span class='id identifier rubyid_respond_to'>respond_to</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_format'>format</span><span class='op'>|</span>
529
+ <span class='comment'># Form posts trigger format types turbo stream and then html, turbo stream wins.
530
+ </span> <span class='comment'># For this reason, Rails prefers stream, in which case the layout is disabled, regardless of the option.
531
+ </span> <span class='comment'># To mitigate this, we use respond_to to force a HTML-only response.
532
+ </span> <span class='id identifier rubyid_format'>format</span><span class='period'>.</span><span class='id identifier rubyid_html'>html</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_controller'>controller</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
533
+ <span class='kw'>end</span>
534
+ <span class='kw'>end</span>
535
+ <span class='kw'>end</span></pre>
536
+ </td>
537
+ </tr>
538
+ </table>
539
+ </div>
540
+
541
+ <div class="method_details ">
542
+ <h3 class="signature " id="standalone-instance_method">
543
+
544
+ #<strong>standalone</strong>(name = nil, *args, **nargs, &amp;block) &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
545
+
546
+
547
+
548
+
549
+
550
+ </h3><div class="docstring">
551
+ <div class="discussion">
552
+
553
+ <p>DSL method This can be called multiple times to make a component listen to multiple paths. Each standalone config (path) has a name, the default being <code>nil</code>. To have a component listen to multiple paths, call standalone again and provide a name, e.g.: standalone(:autocomplete, path: ‘foo/bar/autocomplete’) The kwarg parameter <code>path</code> is handled analog to the Rails route path</p>
554
+
555
+
556
+ </div>
557
+ </div>
558
+ <div class="tags">
559
+ <p class="tag_title">Parameters:</p>
560
+ <ul class="param">
561
+
562
+ <li>
563
+
564
+ <span class='name'>name</span>
565
+
566
+
567
+ <span class='type'>(<tt>Symbol</tt>, <tt>nil</tt>)</span>
568
+
569
+
570
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
571
+
572
+
573
+ &mdash;
574
+ <div class='inline'>
575
+ <p>The name of the standalone config, defaults to nil. Only provide if you add additional configs.</p>
576
+ </div>
577
+
578
+ </li>
579
+
580
+ </ul>
581
+
582
+
583
+ </div><table class="source_code">
584
+ <tr>
585
+ <td>
586
+ <pre class="lines">
587
+
588
+
589
+ 111
590
+ 112
591
+ 113
592
+ 114
593
+ 115
594
+ 116
595
+ 117
596
+ 118
597
+ 119</pre>
598
+ </td>
599
+ <td>
600
+ <pre class="code"><span class="info file"># File 'lib/compony/component_mixins/default/standalone.rb', line 111</span>
601
+
602
+ <span class='kw'>def</span> <span class='id identifier rubyid_standalone'>standalone</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_nargs'>nargs</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
603
+ <span class='id identifier rubyid_block'>block</span> <span class='op'>=</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='comment'># If called without a block, must default to an empty block to provide a binding to the DSL.
604
+ </span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='op'>&amp;.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='comment'># nil name is the most common case
605
+ </span> <span class='kw'>if</span> <span class='ivar'>@standalone_configs</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>
606
+ <span class='ivar'>@standalone_configs</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_deep_merge!'>deep_merge!</span> <span class='const'><span class='object_link'><a href="Standalone/StandaloneDsl.html" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl (class)">StandaloneDsl</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Standalone/StandaloneDsl.html#initialize-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='label'>provide_defaults:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_nargs'>nargs</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_conf'><span class='object_link'><a href="Standalone/StandaloneDsl.html#to_conf-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#to_conf (method)">to_conf</a></span></span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
607
+ <span class='kw'>else</span>
608
+ <span class='ivar'>@standalone_configs</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../../Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../MethodAccessibleHash.html" title="Compony::MethodAccessibleHash (class)">MethodAccessibleHash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../../MethodAccessibleHash.html#initialize-instance_method" title="Compony::MethodAccessibleHash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Standalone/StandaloneDsl.html" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl (class)">StandaloneDsl</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Standalone/StandaloneDsl.html#initialize-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='label'>provide_defaults:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_nargs'>nargs</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_conf'><span class='object_link'><a href="Standalone/StandaloneDsl.html#to_conf-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#to_conf (method)">to_conf</a></span></span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span><span class='rparen'>)</span>
609
+ <span class='kw'>end</span>
610
+ <span class='kw'>end</span></pre>
611
+ </td>
612
+ </tr>
613
+ </table>
614
+ </div>
615
+
616
+ <div class="method_details ">
617
+ <h3 class="signature " id="standalone_access_permitted_for?-instance_method">
618
+
619
+ #<strong>standalone_access_permitted_for?</strong>(controller, standalone_name: nil, verb: nil) &#x21d2; <tt>Boolean</tt>
620
+
621
+
622
+
623
+
624
+
625
+ </h3><div class="docstring">
626
+ <div class="discussion">
627
+
628
+ <p>Call this on a standalone component to find out whether default GET access is permitted for the current user. This is useful to hide/disable buttons leading to components a user may not press. For resourceful components, before calling this, you must have loaded date beforehand, for instance in one of the following ways: - when called standalone (via request to the component), the load data step must be completed - when called to check for permission only, e.g. to display a button to it, initialize the component by passing the :data keyword to <code>new</code> By default, this checks the authorization to access the main standalone entrypoint (with name <code>nil</code>) and HTTP verb GET.</p>
629
+
630
+
631
+ </div>
632
+ </div>
633
+ <div class="tags">
634
+
635
+ <p class="tag_title">Returns:</p>
636
+ <ul class="return">
637
+
638
+ <li>
639
+
640
+
641
+ <span class='type'>(<tt>Boolean</tt>)</span>
642
+
643
+
644
+
645
+ </li>
646
+
647
+ </ul>
648
+
649
+ </div><table class="source_code">
650
+ <tr>
651
+ <td>
652
+ <pre class="lines">
653
+
654
+
655
+ 78
656
+ 79
657
+ 80
658
+ 81
659
+ 82
660
+ 83
661
+ 84
662
+ 85</pre>
663
+ </td>
664
+ <td>
665
+ <pre class="code"><span class="info file"># File 'lib/compony/component_mixins/default/standalone.rb', line 78</span>
666
+
667
+ <span class='kw'>def</span> <span class='id identifier rubyid_standalone_access_permitted_for?'>standalone_access_permitted_for?</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='label'>standalone_name:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>verb:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
668
+ <span class='id identifier rubyid_verb'>verb</span> <span class='op'>||=</span> <span class='symbol'>:get</span>
669
+ <span class='id identifier rubyid_standalone_name'>standalone_name</span> <span class='op'>=</span> <span class='id identifier rubyid_standalone_name'>standalone_name</span><span class='op'>&amp;.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
670
+ <span class='id identifier rubyid_verb'>verb</span> <span class='op'>=</span> <span class='id identifier rubyid_verb'>verb</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
671
+ <span class='id identifier rubyid_standalone_config'>standalone_config</span> <span class='op'>=</span> <span class='id identifier rubyid_standalone_configs'>standalone_configs</span><span class='lbracket'>[</span><span class='id identifier rubyid_standalone_name'>standalone_name</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> does not provide the standalone config </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_standalone_config'>standalone_config</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
672
+ <span class='id identifier rubyid_verb'>verb</span> <span class='op'>=</span> <span class='id identifier rubyid_standalone_config'>standalone_config</span><span class='period'>.</span><span class='id identifier rubyid_verbs'>verbs</span><span class='lbracket'>[</span><span class='id identifier rubyid_verb'>verb</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> standalone config </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_standalone_config'>standalone_config</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> does not provide verb </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_verb'>verb</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
673
+ <span class='kw'>return</span> <span class='const'><span class='object_link'><a href="../../RequestContext.html" title="Compony::RequestContext (class)">RequestContext</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../../RequestContext.html#initialize-instance_method" title="Compony::RequestContext#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_controller'>controller</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_verb'>verb</span><span class='period'>.</span><span class='id identifier rubyid_authorize_block'>authorize_block</span><span class='rparen'>)</span>
674
+ <span class='kw'>end</span></pre>
675
+ </td>
676
+ </tr>
677
+ </table>
678
+ </div>
679
+
680
+ </div>
681
+
682
+ </div>
683
+
684
+ <div id="footer">
685
+ Generated on Wed Apr 24 17:14:06 2024 by
686
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
687
+ 0.9.34 (ruby-3.2.2).
688
+ </div>
689
+
690
+ </div>
691
+ </body>
692
+ </html>