anchormodel 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +10 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.md +114 -3
  6. data/VERSION +1 -1
  7. data/anchormodel.gemspec +5 -5
  8. data/doc/Anchormodel/ActiveModelTypeValueSingle.html +697 -0
  9. data/doc/Anchormodel/Attribute.html +109 -9
  10. data/doc/Anchormodel/ModelMixin.html +75 -3
  11. data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +269 -0
  12. data/doc/Anchormodel/SimpleFormInputs/Helpers.html +124 -0
  13. data/doc/Anchormodel/SimpleFormInputs.html +124 -0
  14. data/doc/Anchormodel/Util.html +612 -0
  15. data/doc/Anchormodel/Version.html +3 -3
  16. data/doc/Anchormodel.html +99 -34
  17. data/doc/AnchormodelGenerator.html +201 -0
  18. data/doc/AnchormodelInput.html +140 -0
  19. data/doc/AnchormodelRadioButtonsInput.html +140 -0
  20. data/doc/_index.html +63 -4
  21. data/doc/class_list.html +1 -1
  22. data/doc/file.README.html +109 -6
  23. data/doc/frames.html +5 -10
  24. data/doc/index.html +109 -6
  25. data/doc/method_list.html +70 -6
  26. data/doc/top-level-namespace.html +4 -4
  27. data/lib/anchormodel/active_model_type_value_multi.rb +31 -0
  28. data/lib/anchormodel/active_model_type_value_single.rb +4 -2
  29. data/lib/anchormodel/attribute.rb +7 -1
  30. data/lib/anchormodel/model_mixin.rb +7 -0
  31. data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +23 -0
  32. data/lib/anchormodel/simple_form_inputs/anchormodel_input.rb +21 -0
  33. data/lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb +23 -0
  34. data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +54 -0
  35. data/lib/anchormodel/util.rb +57 -7
  36. data/lib/anchormodel.rb +10 -0
  37. data/test/active_record_model/user_test.rb +73 -9
  38. data/test/dummy/app/anchormodels/animal.rb +6 -0
  39. data/test/dummy/app/models/user.rb +1 -0
  40. data/test/dummy/db/migrate/20240425182000_add_animals_to_users.rb +5 -0
  41. data/test/dummy/db/schema.rb +2 -1
  42. metadata +18 -4
  43. data/pkg/anchormodel-0.1.3.gem +0 -0
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Class: Anchormodel::Attribute
8
8
 
9
- &mdash; Documentation by YARD 0.9.36
9
+ &mdash; Documentation by YARD 0.9.34
10
10
 
11
11
  </title>
12
12
 
@@ -214,7 +214,7 @@
214
214
  <li class="public ">
215
215
  <span class="summary_signature">
216
216
 
217
- <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false) &#x21d2; Attribute </a>
217
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false, multiple = false) &#x21d2; Attribute </a>
218
218
 
219
219
 
220
220
 
@@ -234,6 +234,28 @@
234
234
  <p>A new instance of Attribute.</p>
235
235
  </div></span>
236
236
 
237
+ </li>
238
+
239
+
240
+ <li class="public ">
241
+ <span class="summary_signature">
242
+
243
+ <a href="#multiple%3F-instance_method" title="#multiple? (instance method)">#<strong>multiple?</strong> &#x21d2; Boolean </a>
244
+
245
+
246
+
247
+ </span>
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <span class="summary_desc"><div class='inline'></div></span>
258
+
237
259
  </li>
238
260
 
239
261
 
@@ -246,7 +268,7 @@
246
268
  <div class="method_details first">
247
269
  <h3 class="signature first" id="initialize-instance_method">
248
270
 
249
- #<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false) &#x21d2; <tt><span class='object_link'><a href="" title="Anchormodel::Attribute (class)">Attribute</a></span></tt>
271
+ #<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false, multiple = false) &#x21d2; <tt><span class='object_link'><a href="" title="Anchormodel::Attribute (class)">Attribute</a></span></tt>
250
272
 
251
273
 
252
274
 
@@ -328,6 +350,24 @@
328
350
  &mdash;
329
351
  <div class='inline'>
330
352
  <p>If true, a presence validation is added to the model.</p>
353
+ </div>
354
+
355
+ </li>
356
+
357
+ <li>
358
+
359
+ <span class='name'>multiple</span>
360
+
361
+
362
+ <span class='type'>(<tt>Boolean</tt>)</span>
363
+
364
+
365
+ <em class="default">(defaults to: <tt>false</tt>)</em>
366
+
367
+
368
+ &mdash;
369
+ <div class='inline'>
370
+ <p>If true, this attribute holds multiple anchormodels.</p>
331
371
  </div>
332
372
 
333
373
  </li>
@@ -341,21 +381,23 @@
341
381
  <pre class="lines">
342
382
 
343
383
 
344
- 13
345
384
  14
346
385
  15
347
386
  16
348
387
  17
349
- 18</pre>
388
+ 18
389
+ 19
390
+ 20</pre>
350
391
  </td>
351
392
  <td>
352
- <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 13</span>
393
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 14</span>
353
394
 
354
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_optional'>optional</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
395
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_optional'>optional</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_multiple'>multiple</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
355
396
  <span class='ivar'>@model_class</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span>
356
397
  <span class='ivar'>@attribute_name</span> <span class='op'>=</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
357
398
  <span class='ivar'>@anchormodel_class</span> <span class='op'>=</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
358
399
  <span class='ivar'>@optional</span> <span class='op'>=</span> <span class='id identifier rubyid_optional'>optional</span>
400
+ <span class='ivar'>@multiple</span> <span class='op'>=</span> <span class='id identifier rubyid_multiple'>multiple</span>
359
401
  <span class='kw'>end</span></pre>
360
402
  </td>
361
403
  </tr>
@@ -493,12 +535,70 @@
493
535
  </div>
494
536
 
495
537
 
538
+ <div id="instance_method_details" class="method_details_list">
539
+ <h2>Instance Method Details</h2>
540
+
541
+
542
+ <div class="method_details first">
543
+ <h3 class="signature first" id="multiple?-instance_method">
544
+
545
+ #<strong>multiple?</strong> &#x21d2; <tt>Boolean</tt>
546
+
547
+
548
+
549
+
550
+
551
+ </h3><div class="docstring">
552
+ <div class="discussion">
553
+
554
+
555
+ </div>
556
+ </div>
557
+ <div class="tags">
558
+
559
+ <p class="tag_title">Returns:</p>
560
+ <ul class="return">
561
+
562
+ <li>
563
+
564
+
565
+ <span class='type'>(<tt>Boolean</tt>)</span>
566
+
567
+
568
+
569
+ </li>
570
+
571
+ </ul>
572
+
573
+ </div><table class="source_code">
574
+ <tr>
575
+ <td>
576
+ <pre class="lines">
577
+
578
+
579
+ 22
580
+ 23
581
+ 24</pre>
582
+ </td>
583
+ <td>
584
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 22</span>
585
+
586
+ <span class='kw'>def</span> <span class='id identifier rubyid_multiple?'>multiple?</span>
587
+ <span class='ivar'>@multiple</span>
588
+ <span class='kw'>end</span></pre>
589
+ </td>
590
+ </tr>
591
+ </table>
592
+ </div>
593
+
594
+ </div>
595
+
496
596
  </div>
497
597
 
498
598
  <div id="footer">
499
- Generated on Tue Apr 23 17:20:43 2024 by
599
+ Generated on Sat Apr 27 10:18:33 2024 by
500
600
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
501
- 0.9.36 (ruby-3.2.2).
601
+ 0.9.34 (ruby-3.2.2).
502
602
  </div>
503
603
 
504
604
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Module: Anchormodel::ModelMixin
8
8
 
9
- &mdash; Documentation by YARD 0.9.36
9
+ &mdash; Documentation by YARD 0.9.34
10
10
 
11
11
  </title>
12
12
 
@@ -135,6 +135,30 @@
135
135
  <p>Creates an attribute linking to an Anchormodel.</p>
136
136
  </div></span>
137
137
 
138
+ </li>
139
+
140
+
141
+ <li class="public ">
142
+ <span class="summary_signature">
143
+
144
+ <a href="#belongs_to_anchormodels-class_method" title="belongs_to_anchormodels (class method)">.<strong>belongs_to_anchormodels</strong>(*args, **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'>
159
+ <p>Creates an attribute linking to an array of Anchormodels.</p>
160
+ </div></span>
161
+
138
162
  </li>
139
163
 
140
164
 
@@ -194,6 +218,54 @@
194
218
  </td>
195
219
  </tr>
196
220
  </table>
221
+ </div>
222
+
223
+ <div class="method_details ">
224
+ <h3 class="signature " id="belongs_to_anchormodels-class_method">
225
+
226
+ .<strong>belongs_to_anchormodels</strong>(*args, **kwargs) &#x21d2; <tt>Object</tt>
227
+
228
+
229
+
230
+
231
+
232
+ </h3><div class="docstring">
233
+ <div class="discussion">
234
+
235
+ <p>Creates an attribute linking to an array of Anchormodels. The attribute should be present in the DB and the column should be named the singular of <code>attribute_name</code>.</p>
236
+
237
+
238
+ </div>
239
+ </div>
240
+ <div class="tags">
241
+
242
+
243
+ <p class="tag_title">See Also:</p>
244
+ <ul class="see">
245
+
246
+ <li>Parameters</li>
247
+
248
+ </ul>
249
+
250
+ </div><table class="source_code">
251
+ <tr>
252
+ <td>
253
+ <pre class="lines">
254
+
255
+
256
+ 21
257
+ 22
258
+ 23</pre>
259
+ </td>
260
+ <td>
261
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/model_mixin.rb', line 21</span>
262
+
263
+ <span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_anchormodels'>belongs_to_anchormodels</span><span class='lparen'>(</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_kwargs'>kwargs</span><span class='rparen'>)</span>
264
+ <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util.html" title="Anchormodel::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_install_methods_in_model'><span class='object_link'><a href="Util.html#install_methods_in_model-class_method" title="Anchormodel::Util.install_methods_in_model (method)">install_methods_in_model</a></span></span><span class='lparen'>(</span><span class='kw'>self</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_kwargs'>kwargs</span><span class='comma'>,</span> <span class='label'>multiple:</span> <span class='kw'>true</span><span class='rparen'>)</span>
265
+ <span class='kw'>end</span></pre>
266
+ </td>
267
+ </tr>
268
+ </table>
197
269
  </div>
198
270
 
199
271
  </div>
@@ -201,9 +273,9 @@
201
273
  </div>
202
274
 
203
275
  <div id="footer">
204
- Generated on Tue Apr 23 17:20:43 2024 by
276
+ Generated on Sat Apr 27 10:18:33 2024 by
205
277
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
206
- 0.9.36 (ruby-3.2.2).
278
+ 0.9.34 (ruby-3.2.2).
207
279
  </div>
208
280
 
209
281
  </div>
@@ -0,0 +1,269 @@
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: Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon
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 = "Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon";
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 (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../SimpleFormInputs.html" title="Anchormodel::SimpleFormInputs (module)">SimpleFormInputs</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Helpers.html" title="Anchormodel::SimpleFormInputs::Helpers (module)">Helpers</a></span></span>
41
+ &raquo;
42
+ <span class="title">AnchormodelInputsCommon</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: Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dl>
78
+ <dt>Included in:</dt>
79
+ <dd><span class='object_link'><a href="../../../AnchormodelCheckBoxesInput.html" title="AnchormodelCheckBoxesInput (class)">AnchormodelCheckBoxesInput</a></span>, <span class='object_link'><a href="../../../AnchormodelInput.html" title="AnchormodelInput (class)">AnchormodelInput</a></span>, <span class='object_link'><a href="../../../AnchormodelRadioButtonsInput.html" title="AnchormodelRadioButtonsInput (class)">AnchormodelRadioButtonsInput</a></span></dd>
80
+ </dl>
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <div class="docstring">
92
+ <div class="discussion">
93
+
94
+
95
+ </div>
96
+ </div>
97
+ <div class="tags">
98
+
99
+
100
+ </div>
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <h2>
109
+ Instance Method Summary
110
+ <small><a href="#" class="summary_toggle">collapse</a></small>
111
+ </h2>
112
+
113
+ <ul class="summary">
114
+
115
+ <li class="public ">
116
+ <span class="summary_signature">
117
+
118
+ <a href="#input-instance_method" title="#input (instance method)">#<strong>input</strong>(wrapper_options = nil) &#x21d2; Object </a>
119
+
120
+
121
+
122
+ </span>
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <span class="summary_desc"><div class='inline'></div></span>
133
+
134
+ </li>
135
+
136
+
137
+ </ul>
138
+
139
+
140
+
141
+
142
+ <div id="instance_method_details" class="method_details_list">
143
+ <h2>Instance Method Details</h2>
144
+
145
+
146
+ <div class="method_details first">
147
+ <h3 class="signature first" id="input-instance_method">
148
+
149
+ #<strong>input</strong>(wrapper_options = nil) &#x21d2; <tt>Object</tt>
150
+
151
+
152
+
153
+
154
+
155
+ </h3><div class="docstring">
156
+ <div class="discussion">
157
+
158
+
159
+ </div>
160
+ </div>
161
+ <div class="tags">
162
+
163
+
164
+ </div><table class="source_code">
165
+ <tr>
166
+ <td>
167
+ <pre class="lines">
168
+
169
+
170
+ 5
171
+ 6
172
+ 7
173
+ 8
174
+ 9
175
+ 10
176
+ 11
177
+ 12
178
+ 13
179
+ 14
180
+ 15
181
+ 16
182
+ 17
183
+ 18
184
+ 19
185
+ 20
186
+ 21
187
+ 22
188
+ 23
189
+ 24
190
+ 25
191
+ 26
192
+ 27
193
+ 28
194
+ 29
195
+ 30
196
+ 31
197
+ 32
198
+ 33
199
+ 34
200
+ 35
201
+ 36
202
+ 37
203
+ 38
204
+ 39
205
+ 40
206
+ 41
207
+ 42
208
+ 43</pre>
209
+ </td>
210
+ <td>
211
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb', line 5</span>
212
+
213
+ <span class='kw'>def</span> <span class='id identifier rubyid_input'>input</span><span class='lparen'>(</span><span class='id identifier rubyid_wrapper_options'>wrapper_options</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
214
+ <span class='kw'>unless</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:anchormodel_attributes</span><span class='rparen'>)</span>
215
+ <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'>The form field object does not appear to respond to `anchormodel_attributes`, \
216
+ did you `include Anchormodel::ModelMixin` in your `application_record.rb`? Affected object: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
217
+ <span class='kw'>end</span>
218
+
219
+ <span class='id identifier rubyid_am_attr'>am_attr</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span><span class='lbracket'>[</span><span class='ivar'>@attribute_name</span><span class='rbracket'>]</span>
220
+ <span class='kw'>unless</span> <span class='id identifier rubyid_am_attr'>am_attr</span>
221
+ <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='ivar'>@attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> does not look like an Anchormodel attribute, is `belongs_to_anchormodel` called in your model? \
222
+ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
223
+ <span class='kw'>end</span>
224
+ <span class='id identifier rubyid_am_class'>am_class</span> <span class='op'>=</span> <span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
225
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:multiple</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_multiple?'>multiple?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:multiple</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='kw'>false</span> <span class='comment'># allow overriding
226
+ </span>
227
+ <span class='comment'># Attempt to read selected key from html input options &quot;value&quot;, as the caller might not know that this is a select.
228
+ </span> <span class='id identifier rubyid_selected_key'>selected_key</span> <span class='op'>=</span> <span class='id identifier rubyid_input_options'>input_options</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span>
229
+ <span class='kw'>if</span> <span class='id identifier rubyid_selected_key'>selected_key</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_object'>object</span>
230
+ <span class='comment'># No selected key override present and a model is present, use the model to find out what to select.
231
+ </span> <span class='id identifier rubyid_selected_am'>selected_am</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@attribute_name</span><span class='rparen'>)</span>
232
+ <span class='kw'>if</span> <span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_multiple?'>multiple?</span>
233
+ <span class='id identifier rubyid_selected_key'>selected_key</span> <span class='op'>=</span> <span class='id identifier rubyid_selected_am'>selected_am</span><span class='op'>&amp;.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:key</span><span class='rparen'>)</span><span class='op'>&amp;.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
234
+ <span class='kw'>else</span>
235
+ <span class='id identifier rubyid_selected_key'>selected_key</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_selected_am'>selected_am</span><span class='op'>&amp;.</span><span class='id identifier rubyid_key'>key</span> <span class='op'>||</span> <span class='id identifier rubyid_am_class'>am_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
236
+ <span class='kw'>end</span>
237
+ <span class='kw'>end</span>
238
+
239
+ <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_deep_merge!'>deep_merge!</span><span class='lparen'>(</span>
240
+ <span class='label'>label_method:</span> <span class='symbol'>:first</span><span class='comma'>,</span>
241
+ <span class='label'>value_method:</span> <span class='symbol'>:second</span><span class='comma'>,</span>
242
+ <span class='id identifier rubyid_sf_selection_key'>sf_selection_key</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_selected_key'>selected_key</span><span class='comma'>,</span>
243
+ <span class='label'>include_blank:</span> <span class='op'>!</span><span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_multiple?'>multiple?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_optional'>optional</span>
244
+ <span class='rparen'>)</span>
245
+
246
+ <span class='ivar'>@collection</span> <span class='op'>=</span> <span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='id identifier rubyid_am_class'>am_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='rparen'>)</span>
247
+
248
+ <span class='id identifier rubyid_before_render_input'>before_render_input</span>
249
+
250
+ <span class='kw'>super</span>
251
+ <span class='kw'>end</span></pre>
252
+ </td>
253
+ </tr>
254
+ </table>
255
+ </div>
256
+
257
+ </div>
258
+
259
+ </div>
260
+
261
+ <div id="footer">
262
+ Generated on Sat Apr 27 10:18:33 2024 by
263
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
264
+ 0.9.34 (ruby-3.2.2).
265
+ </div>
266
+
267
+ </div>
268
+ </body>
269
+ </html>