compony 0.2.3 → 0.3.1

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/README.md +90 -13
  4. data/VERSION +1 -1
  5. data/compony.gemspec +4 -4
  6. data/doc/ComponentGenerator.html +1 -1
  7. data/doc/Components.html +1 -1
  8. data/doc/ComponentsGenerator.html +1 -1
  9. data/doc/Compony/Component.html +396 -334
  10. data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
  11. data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
  12. data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +1 -1
  13. data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
  14. data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
  15. data/doc/Compony/ComponentMixins/Default.html +1 -1
  16. data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
  17. data/doc/Compony/ComponentMixins.html +1 -1
  18. data/doc/Compony/Components/Button.html +3 -3
  19. data/doc/Compony/Components/Destroy.html +15 -15
  20. data/doc/Compony/Components/Edit.html +19 -19
  21. data/doc/Compony/Components/Form.html +87 -87
  22. data/doc/Compony/Components/New.html +15 -15
  23. data/doc/Compony/Components/WithForm.html +4 -4
  24. data/doc/Compony/Components.html +1 -1
  25. data/doc/Compony/ControllerMixin.html +1 -1
  26. data/doc/Compony/Engine.html +1 -1
  27. data/doc/Compony/MethodAccessibleHash.html +1 -1
  28. data/doc/Compony/ModelFields/Anchormodel.html +1 -1
  29. data/doc/Compony/ModelFields/Association.html +1 -1
  30. data/doc/Compony/ModelFields/Attachment.html +1 -1
  31. data/doc/Compony/ModelFields/Base.html +1 -1
  32. data/doc/Compony/ModelFields/Boolean.html +1 -1
  33. data/doc/Compony/ModelFields/Color.html +1 -1
  34. data/doc/Compony/ModelFields/Currency.html +1 -1
  35. data/doc/Compony/ModelFields/Date.html +1 -1
  36. data/doc/Compony/ModelFields/Datetime.html +1 -1
  37. data/doc/Compony/ModelFields/Decimal.html +1 -1
  38. data/doc/Compony/ModelFields/Email.html +1 -1
  39. data/doc/Compony/ModelFields/Float.html +1 -1
  40. data/doc/Compony/ModelFields/Integer.html +1 -1
  41. data/doc/Compony/ModelFields/Percentage.html +1 -1
  42. data/doc/Compony/ModelFields/Phone.html +1 -1
  43. data/doc/Compony/ModelFields/RichText.html +1 -1
  44. data/doc/Compony/ModelFields/String.html +1 -1
  45. data/doc/Compony/ModelFields/Text.html +1 -1
  46. data/doc/Compony/ModelFields/Time.html +1 -1
  47. data/doc/Compony/ModelFields/Url.html +1 -1
  48. data/doc/Compony/ModelFields.html +1 -1
  49. data/doc/Compony/ModelMixin.html +1 -1
  50. data/doc/Compony/NaturalOrdering.html +300 -0
  51. data/doc/Compony/RequestContext.html +84 -1
  52. data/doc/Compony/Version.html +1 -1
  53. data/doc/Compony/ViewHelpers.html +1 -1
  54. data/doc/Compony.html +3 -3
  55. data/doc/ComponyController.html +1 -1
  56. data/doc/_index.html +8 -1
  57. data/doc/class_list.html +1 -1
  58. data/doc/file.README.html +82 -16
  59. data/doc/index.html +82 -16
  60. data/doc/method_list.html +169 -161
  61. data/doc/top-level-namespace.html +1 -1
  62. data/lib/compony/component.rb +40 -52
  63. data/lib/compony/components/destroy.rb +9 -1
  64. data/lib/compony/components/edit.rb +2 -4
  65. data/lib/compony/components/form.rb +16 -5
  66. data/lib/compony/components/new.rb +5 -6
  67. data/lib/compony/components/with_form.rb +1 -1
  68. data/lib/compony/natural_ordering.rb +60 -0
  69. data/lib/compony/request_context.rb +14 -0
  70. data/lib/compony.rb +1 -0
  71. metadata +4 -2
@@ -222,7 +222,7 @@
222
222
  </div>
223
223
 
224
224
  <div id="footer">
225
- Generated on Sat Apr 27 10:22:12 2024 by
225
+ Generated on Fri May 31 14:28:30 2024 by
226
226
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
227
227
  0.9.34 (ruby-3.2.2).
228
228
  </div>
@@ -222,7 +222,7 @@
222
222
  </div>
223
223
 
224
224
  <div id="footer">
225
- Generated on Sat Apr 27 10:22:12 2024 by
225
+ Generated on Fri May 31 14:28:30 2024 by
226
226
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
227
227
  0.9.34 (ruby-3.2.2).
228
228
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -230,7 +230,7 @@
230
230
  </div>
231
231
 
232
232
  <div id="footer">
233
- Generated on Sat Apr 27 10:22:12 2024 by
233
+ Generated on Fri May 31 14:28:30 2024 by
234
234
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
235
235
  0.9.34 (ruby-3.2.2).
236
236
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -222,7 +222,7 @@
222
222
  </div>
223
223
 
224
224
  <div id="footer">
225
- Generated on Sat Apr 27 10:22:12 2024 by
225
+ Generated on Fri May 31 14:28:30 2024 by
226
226
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
227
227
  0.9.34 (ruby-3.2.2).
228
228
  </div>
@@ -291,7 +291,7 @@
291
291
  </div>
292
292
 
293
293
  <div id="footer">
294
- Generated on Sat Apr 27 10:22:12 2024 by
294
+ Generated on Fri May 31 14:28:30 2024 by
295
295
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
296
296
  0.9.34 (ruby-3.2.2).
297
297
  </div>
@@ -222,7 +222,7 @@
222
222
  </div>
223
223
 
224
224
  <div id="footer">
225
- Generated on Sat Apr 27 10:22:12 2024 by
225
+ Generated on Fri May 31 14:28:30 2024 by
226
226
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
227
227
  0.9.34 (ruby-3.2.2).
228
228
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -144,7 +144,7 @@
144
144
  </div>
145
145
 
146
146
  <div id="footer">
147
- Generated on Sat Apr 27 10:22:12 2024 by
147
+ Generated on Fri May 31 14:28:30 2024 by
148
148
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
149
149
  0.9.34 (ruby-3.2.2).
150
150
  </div>
@@ -230,7 +230,7 @@
230
230
  </div>
231
231
 
232
232
  <div id="footer">
233
- Generated on Sat Apr 27 10:22:12 2024 by
233
+ Generated on Fri May 31 14:28:30 2024 by
234
234
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
235
235
  0.9.34 (ruby-3.2.2).
236
236
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Apr 27 10:22:11 2024 by
119
+ Generated on Fri May 31 14:28:29 2024 by
120
120
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.9.34 (ruby-3.2.2).
122
122
  </div>
@@ -514,7 +514,7 @@
514
514
  </div>
515
515
 
516
516
  <div id="footer">
517
- Generated on Sat Apr 27 10:22:11 2024 by
517
+ Generated on Fri May 31 14:28:29 2024 by
518
518
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
519
519
  0.9.34 (ruby-3.2.2).
520
520
  </div>
@@ -0,0 +1,300 @@
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
+ Class: Compony::NaturalOrdering
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::NaturalOrdering";
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 (N)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Compony.html" title="Compony (module)">Compony</a></span></span>
41
+ &raquo;
42
+ <span class="title">NaturalOrdering</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>Class: Compony::NaturalOrdering
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Array</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Array</li>
78
+
79
+ <li class="next">Compony::NaturalOrdering</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/compony/natural_ordering.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>This class provides an array-based data structure where elements have symbol names. New elements can be appended or placed at a location using <code>before:</code>. Important: do not mutate this class with any other method call than the natural_-prefixed methods defined below. Example:<br></p>
108
+
109
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_collection'>collection</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'>NaturalOrdering</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
110
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:a</span><span class='comma'>,</span> <span class='id identifier rubyid_a_payload'>a_payload</span><span class='rparen'>)</span>
111
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:c</span><span class='comma'>,</span> <span class='id identifier rubyid_c_payload'>c_payload</span><span class='rparen'>)</span>
112
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:b</span><span class='comma'>,</span> <span class='id identifier rubyid_b_payload'>b_payload</span><span class='comma'>,</span> <span class='label'>before:</span> <span class='symbol'>:c</span><span class='rparen'>)</span>
113
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:d</span><span class='comma'>,</span> <span class='id identifier rubyid_d_payload'>d_payload</span><span class='comma'>,</span> <span class='label'>hidden:</span> <span class='kw'>true</span><span class='rparen'>)</span>
114
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:a</span><span class='comma'>,</span> <span class='id identifier rubyid_a_new_payload'>a_new_payload</span><span class='rparen'>)</span> <span class='comment'># overwrites :a
115
+ </span>
116
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_hidden'>hidden</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:name</span><span class='rparen'>)</span> <span class='comment'># --&gt; :a, :b, :c
117
+ </span><span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:payload</span><span class='rparen'>)</span> <span class='comment'># --&gt; a_new_payload, b_payload, c_payload, d_payload
118
+ </span></code></pre>
119
+
120
+
121
+ </div>
122
+ </div>
123
+ <div class="tags">
124
+
125
+
126
+ </div>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ <h2>
135
+ Instance Method Summary
136
+ <small><a href="#" class="summary_toggle">collapse</a></small>
137
+ </h2>
138
+
139
+ <ul class="summary">
140
+
141
+ <li class="public ">
142
+ <span class="summary_signature">
143
+
144
+ <a href="#natural_push-instance_method" title="#natural_push (instance method)">#<strong>natural_push</strong>(name, payload = :missing, before: nil, **kwargs) &#x21d2; Object </a>
145
+
146
+
147
+
148
+ </span>
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ <span class="summary_desc"><div class='inline'></div></span>
159
+
160
+ </li>
161
+
162
+
163
+ </ul>
164
+
165
+
166
+
167
+
168
+
169
+ <div id="instance_method_details" class="method_details_list">
170
+ <h2>Instance Method Details</h2>
171
+
172
+
173
+ <div class="method_details first">
174
+ <h3 class="signature first" id="natural_push-instance_method">
175
+
176
+ #<strong>natural_push</strong>(name, payload = :missing, before: nil, **kwargs) &#x21d2; <tt>Object</tt>
177
+
178
+
179
+
180
+
181
+
182
+ </h3><div class="docstring">
183
+ <div class="discussion">
184
+
185
+
186
+ </div>
187
+ </div>
188
+ <div class="tags">
189
+
190
+
191
+ </div><table class="source_code">
192
+ <tr>
193
+ <td>
194
+ <pre class="lines">
195
+
196
+
197
+ 18
198
+ 19
199
+ 20
200
+ 21
201
+ 22
202
+ 23
203
+ 24
204
+ 25
205
+ 26
206
+ 27
207
+ 28
208
+ 29
209
+ 30
210
+ 31
211
+ 32
212
+ 33
213
+ 34
214
+ 35
215
+ 36
216
+ 37
217
+ 38
218
+ 39
219
+ 40
220
+ 41
221
+ 42
222
+ 43
223
+ 44
224
+ 45
225
+ 46
226
+ 47
227
+ 48
228
+ 49
229
+ 50
230
+ 51
231
+ 52
232
+ 53
233
+ 54
234
+ 55
235
+ 56
236
+ 57
237
+ 58</pre>
238
+ </td>
239
+ <td>
240
+ <pre class="code"><span class="info file"># File 'lib/compony/natural_ordering.rb', line 18</span>
241
+
242
+ <span class='kw'>def</span> <span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='symbol'>:missing</span><span class='comma'>,</span> <span class='label'>before:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
243
+ <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
244
+ <span class='id identifier rubyid_before_name'>before_name</span> <span class='op'>=</span> <span class='id identifier rubyid_before'>before</span><span class='op'>&amp;.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
245
+ <span class='id identifier rubyid_old_kwargs'>old_kwargs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
246
+ <span class='id identifier rubyid_old_payload'>old_payload</span> <span class='op'>=</span> <span class='kw'>nil</span>
247
+
248
+ <span class='comment'># Fetch existing element if any
249
+ </span> <span class='id identifier rubyid_existing_index'>existing_index</span> <span class='op'>=</span> <span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='id identifier rubyid_name'>name</span> <span class='rbrace'>}</span>
250
+ <span class='kw'>if</span> <span class='id identifier rubyid_existing_index'>existing_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
251
+ <span class='comment'># Copy all non-mentionned kwargs from the element we are about to overwrite
252
+ </span> <span class='id identifier rubyid_old_kwargs'>old_kwargs</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_except'>except</span><span class='lparen'>(</span><span class='symbol'>:name</span><span class='comma'>,</span> <span class='symbol'>:payload</span><span class='rparen'>)</span>
253
+ <span class='id identifier rubyid_old_payload'>old_payload</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_payload'>payload</span>
254
+
255
+ <span class='comment'># Replacing an existing element with a before: directive - must delete before calculating indices
256
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
257
+ <span class='id identifier rubyid_delete_at'>delete_at</span><span class='lparen'>(</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rparen'>)</span>
258
+ <span class='kw'>end</span>
259
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>==</span> <span class='symbol'>:missing</span>
260
+ <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot insert new element </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> without a payload (payload can only omitted if overriding another element) in </span><span class='embexpr_beg'>#{</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>
261
+ <span class='kw'>end</span>
262
+
263
+ <span class='comment'># Fetch before element
264
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
265
+ <span class='id identifier rubyid_before_index'>before_index</span> <span class='op'>=</span> <span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='id identifier rubyid_before_name'>before_name</span> <span class='rbrace'>}</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='tstring_content'>Element </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> for :before not found in </span><span class='embexpr_beg'>#{</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>
266
+ <span class='kw'>end</span>
267
+
268
+ <span class='comment'># Create the element to insert
269
+ </span> <span class='id identifier rubyid_element'>element</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='label'>name:</span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>==</span> <span class='symbol'>:missing</span> <span class='op'>?</span> <span class='id identifier rubyid_old_payload'>old_payload</span> <span class='op'>:</span> <span class='id identifier rubyid_payload'>payload</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_old_kwargs'>old_kwargs</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span><span class='rparen'>)</span>
270
+
271
+ <span class='comment'># Insert new element
272
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_before_index'>before_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
273
+ <span class='comment'># Insert before another element
274
+ </span> <span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span><span class='id identifier rubyid_before_index'>before_index</span><span class='comma'>,</span> <span class='id identifier rubyid_element'>element</span><span class='rparen'>)</span>
275
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_existing_index'>existing_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
276
+ <span class='comment'># Override another element
277
+ </span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_element'>element</span>
278
+ <span class='kw'>else</span>
279
+ <span class='comment'># Append at the end
280
+ </span> <span class='kw'>self</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_element'>element</span>
281
+ <span class='kw'>end</span>
282
+ <span class='kw'>end</span></pre>
283
+ </td>
284
+ </tr>
285
+ </table>
286
+ </div>
287
+
288
+ </div>
289
+
290
+ </div>
291
+
292
+ <div id="footer">
293
+ Generated on Fri May 31 14:28:30 2024 by
294
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
295
+ 0.9.34 (ruby-3.2.2).
296
+ </div>
297
+
298
+ </div>
299
+ </body>
300
+ </html>
@@ -234,6 +234,30 @@
234
234
 
235
235
  <span class="summary_desc"><div class='inline'></div></span>
236
236
 
237
+ </li>
238
+
239
+
240
+ <li class="public ">
241
+ <span class="summary_signature">
242
+
243
+ <a href="#content-instance_method" title="#content (instance method)">#<strong>content</strong>(name) &#x21d2; Object </a>
244
+
245
+
246
+
247
+ </span>
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <span class="summary_desc"><div class='inline'>
258
+ <p>Renders a content block from the current component.</p>
259
+ </div></span>
260
+
237
261
  </li>
238
262
 
239
263
 
@@ -640,6 +664,65 @@
640
664
  </td>
641
665
  </tr>
642
666
  </table>
667
+ </div>
668
+
669
+ <div class="method_details ">
670
+ <h3 class="signature " id="content-instance_method">
671
+
672
+ #<strong>content</strong>(name) &#x21d2; <tt>Object</tt>
673
+
674
+
675
+
676
+
677
+
678
+ </h3><div class="docstring">
679
+ <div class="discussion">
680
+
681
+ <p>Renders a content block from the current component.</p>
682
+
683
+
684
+ </div>
685
+ </div>
686
+ <div class="tags">
687
+
688
+
689
+ </div><table class="source_code">
690
+ <tr>
691
+ <td>
692
+ <pre class="lines">
693
+
694
+
695
+ 46
696
+ 47
697
+ 48
698
+ 49
699
+ 50
700
+ 51
701
+ 52
702
+ 53
703
+ 54
704
+ 55
705
+ 56
706
+ 57</pre>
707
+ </td>
708
+ <td>
709
+ <pre class="code"><span class="info file"># File 'lib/compony/request_context.rb', line 46</span>
710
+
711
+ <span class='kw'>def</span> <span class='id identifier rubyid_content'>content</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
712
+ <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
713
+ <span class='id identifier rubyid_content_block'>content_block</span> <span class='op'>=</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_content_blocks'>content_blocks</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='id identifier rubyid_name'>name</span> <span class='rbrace'>}</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='tstring_content'>Content block </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> not found in </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_component'>component</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>
714
+ <span class='comment'># We have to clear Rails&#39; output_buffer to prevent double rendering of blocks. To achieve this, a fresh render context is instanciated.
715
+ </span> <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_controller'>controller</span><span class='period'>.</span><span class='id identifier rubyid_render_to_string'>render_to_string</span><span class='lparen'>(</span>
716
+ <span class='label'>type:</span> <span class='symbol'>:dyny</span><span class='comma'>,</span>
717
+ <span class='label'>locals:</span> <span class='lbrace'>{</span> <span class='label'>render_component:</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='label'>render_controller:</span> <span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='label'>render_locals:</span> <span class='id identifier rubyid_local_assigns'>local_assigns</span><span class='comma'>,</span> <span class='label'>render_block:</span> <span class='id identifier rubyid_content_block'>content_block</span> <span class='rbrace'>}</span><span class='comma'>,</span>
718
+ <span class='label'>inline:</span> <span class='heredoc_beg'>&lt;&lt;~RUBY</span>
719
+ <span class='tstring_content'> Compony::RequestContext.new(render_component, render_controller, helpers: self, locals: local_assigns).evaluate_with_backfire(&amp;render_block.payload)
720
+ </span><span class='heredoc_end'> RUBY
721
+ </span> <span class='rparen'>)</span>
722
+ <span class='kw'>end</span></pre>
723
+ </td>
724
+ </tr>
725
+ </table>
643
726
  </div>
644
727
 
645
728
  <div class="method_details ">
@@ -781,7 +864,7 @@
781
864
  </div>
782
865
 
783
866
  <div id="footer">
784
- Generated on Sat Apr 27 10:22:12 2024 by
867
+ Generated on Fri May 31 14:28:30 2024 by
785
868
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
786
869
  0.9.34 (ruby-3.2.2).
787
870
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Sat Apr 27 10:22:11 2024 by
132
+ Generated on Fri May 31 14:28:29 2024 by
133
133
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.9.34 (ruby-3.2.2).
135
135
  </div>
@@ -433,7 +433,7 @@
433
433
  </div>
434
434
 
435
435
  <div id="footer">
436
- Generated on Sat Apr 27 10:22:11 2024 by
436
+ Generated on Fri May 31 14:28:29 2024 by
437
437
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
438
438
  0.9.34 (ruby-3.2.2).
439
439
  </div>
data/doc/Compony.html CHANGED
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
81
  <dd>lib/compony.rb<span class="defines">,<br />
82
- lib/compony/engine.rb,<br /> lib/compony/version.rb,<br /> lib/compony/component.rb,<br /> lib/compony/model_mixin.rb,<br /> lib/compony/view_helpers.rb,<br /> lib/compony/components/new.rb,<br /> lib/compony/components/edit.rb,<br /> lib/compony/components/form.rb,<br /> lib/compony/request_context.rb,<br /> lib/compony/controller_mixin.rb,<br /> lib/compony/model_fields/url.rb,<br /> lib/compony/components/button.rb,<br /> lib/compony/model_fields/base.rb,<br /> lib/compony/model_fields/date.rb,<br /> lib/compony/model_fields/text.rb,<br /> lib/compony/model_fields/time.rb,<br /> lib/compony/components/destroy.rb,<br /> lib/compony/model_fields/color.rb,<br /> lib/compony/model_fields/email.rb,<br /> lib/compony/model_fields/float.rb,<br /> lib/compony/model_fields/phone.rb,<br /> lib/compony/model_fields/string.rb,<br /> lib/compony/components/with_form.rb,<br /> lib/compony/model_fields/boolean.rb,<br /> lib/compony/model_fields/decimal.rb,<br /> lib/compony/model_fields/integer.rb,<br /> lib/compony/model_fields/currency.rb,<br /> lib/compony/model_fields/datetime.rb,<br /> lib/compony/method_accessible_hash.rb,<br /> lib/compony/model_fields/rich_text.rb,<br /> lib/compony/model_fields/attachment.rb,<br /> lib/compony/model_fields/percentage.rb,<br /> lib/compony/model_fields/anchormodel.rb,<br /> lib/compony/model_fields/association.rb,<br /> lib/compony/component_mixins/resourceful.rb,<br /> lib/compony/component_mixins/default/labelling.rb,<br /> lib/compony/component_mixins/default/standalone.rb,<br /> 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>
82
+ lib/compony/engine.rb,<br /> lib/compony/version.rb,<br /> lib/compony/component.rb,<br /> lib/compony/model_mixin.rb,<br /> lib/compony/view_helpers.rb,<br /> lib/compony/components/new.rb,<br /> lib/compony/components/edit.rb,<br /> lib/compony/components/form.rb,<br /> lib/compony/request_context.rb,<br /> lib/compony/controller_mixin.rb,<br /> lib/compony/model_fields/url.rb,<br /> lib/compony/natural_ordering.rb,<br /> lib/compony/components/button.rb,<br /> lib/compony/model_fields/base.rb,<br /> lib/compony/model_fields/date.rb,<br /> lib/compony/model_fields/text.rb,<br /> lib/compony/model_fields/time.rb,<br /> lib/compony/components/destroy.rb,<br /> lib/compony/model_fields/color.rb,<br /> lib/compony/model_fields/email.rb,<br /> lib/compony/model_fields/float.rb,<br /> lib/compony/model_fields/phone.rb,<br /> lib/compony/model_fields/string.rb,<br /> lib/compony/components/with_form.rb,<br /> lib/compony/model_fields/boolean.rb,<br /> lib/compony/model_fields/decimal.rb,<br /> lib/compony/model_fields/integer.rb,<br /> lib/compony/model_fields/currency.rb,<br /> lib/compony/model_fields/datetime.rb,<br /> lib/compony/method_accessible_hash.rb,<br /> lib/compony/model_fields/rich_text.rb,<br /> lib/compony/model_fields/attachment.rb,<br /> lib/compony/model_fields/percentage.rb,<br /> lib/compony/model_fields/anchormodel.rb,<br /> lib/compony/model_fields/association.rb,<br /> lib/compony/component_mixins/resourceful.rb,<br /> lib/compony/component_mixins/default/labelling.rb,<br /> lib/compony/component_mixins/default/standalone.rb,<br /> 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>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -111,7 +111,7 @@
111
111
 
112
112
 
113
113
 
114
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Compony/Component.html" title="Compony::Component (class)">Component</a></span>, <span class='object_link'><a href="Compony/Engine.html" title="Compony::Engine (class)">Engine</a></span>, <span class='object_link'><a href="Compony/MethodAccessibleHash.html" title="Compony::MethodAccessibleHash (class)">MethodAccessibleHash</a></span>, <span class='object_link'><a href="Compony/RequestContext.html" title="Compony::RequestContext (class)">RequestContext</a></span>
114
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Compony/Component.html" title="Compony::Component (class)">Component</a></span>, <span class='object_link'><a href="Compony/Engine.html" title="Compony::Engine (class)">Engine</a></span>, <span class='object_link'><a href="Compony/MethodAccessibleHash.html" title="Compony::MethodAccessibleHash (class)">MethodAccessibleHash</a></span>, <span class='object_link'><a href="Compony/NaturalOrdering.html" title="Compony::NaturalOrdering (class)">NaturalOrdering</a></span>, <span class='object_link'><a href="Compony/RequestContext.html" title="Compony::RequestContext (class)">RequestContext</a></span>
115
115
 
116
116
 
117
117
  </p>
@@ -2146,7 +2146,7 @@
2146
2146
  </div>
2147
2147
 
2148
2148
  <div id="footer">
2149
- Generated on Sat Apr 27 10:22:11 2024 by
2149
+ Generated on Fri May 31 14:28:29 2024 by
2150
2150
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2151
2151
  0.9.34 (ruby-3.2.2).
2152
2152
  </div>