anchormodel 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/EXAMPLES.md +408 -0
- data/Gemfile.lock +1 -1
- data/README.md +43 -1
- data/VERSION +1 -1
- data/anchormodel.gemspec +3 -3
- data/bin/test +9 -0
- data/doc/Anchormodel/ActiveModelTypeValueMulti.html +204 -42
- data/doc/Anchormodel/ActiveModelTypeValueSingle.html +243 -54
- data/doc/Anchormodel/Attribute.html +60 -37
- data/doc/Anchormodel/ModelMixin.html +166 -16
- data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +82 -21
- data/doc/Anchormodel/SimpleFormInputs/Helpers.html +2 -11
- data/doc/Anchormodel/SimpleFormInputs.html +2 -11
- data/doc/Anchormodel/Util.html +497 -38
- data/doc/Anchormodel/Version.html +2 -20
- data/doc/Anchormodel.html +536 -129
- data/doc/AnchormodelCheckBoxesInput.html +22 -1
- data/doc/AnchormodelGenerator.html +64 -13
- data/doc/AnchormodelInput.html +24 -1
- data/doc/AnchormodelRadioButtonsInput.html +22 -1
- data/doc/_index.html +16 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +40 -2
- data/doc/index.html +40 -2
- data/doc/method_list.html +57 -17
- data/doc/top-level-namespace.html +1 -1
- data/lib/anchormodel/active_model_type_value_multi.rb +31 -5
- data/lib/anchormodel/active_model_type_value_single.rb +34 -6
- data/lib/anchormodel/attribute.rb +20 -8
- data/lib/anchormodel/model_mixin.rb +43 -8
- data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +7 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_input.rb +9 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb +7 -0
- data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +14 -0
- data/lib/anchormodel/util.rb +102 -17
- data/lib/anchormodel.rb +109 -15
- data/lib/generators/anchormodel/anchormodel_generator.rb +8 -0
- data/test/active_record_model/user_test.rb +221 -10
- data/test/dummy/app/anchormodels/animal.rb +1 -0
- metadata +3 -1
|
@@ -88,9 +88,13 @@
|
|
|
88
88
|
|
|
89
89
|
</div>
|
|
90
90
|
|
|
91
|
-
<div class="docstring">
|
|
91
|
+
<h2>Overview</h2><div class="docstring">
|
|
92
92
|
<div class="discussion">
|
|
93
93
|
|
|
94
|
+
<p>Shared logic for all anchormodel SimpleForm inputs (<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>, <span class='object_link'><a href="../../../AnchormodelCheckBoxesInput.html" title="AnchormodelCheckBoxesInput (class)">AnchormodelCheckBoxesInput</a></span>). Resolves the anchormodel class from the bound object, builds the collection of label/key tuples, and computes the currently-selected key(s).</p>
|
|
95
|
+
|
|
96
|
+
<p>Callers can supply a custom <code>:collection</code> (either an array of anchormodels or an array of <code>[label, key]</code> tuples) to override the default of <code>am_class.all</code>. Callers without a bound <code>object</code> must pass <code>:anchormodel_attribute</code> explicitly.</p>
|
|
97
|
+
|
|
94
98
|
|
|
95
99
|
</div>
|
|
96
100
|
</div>
|
|
@@ -115,7 +119,7 @@
|
|
|
115
119
|
<li class="public ">
|
|
116
120
|
<span class="summary_signature">
|
|
117
121
|
|
|
118
|
-
<a href="#input-instance_method" title="#input (instance method)">#<strong>input</strong>(wrapper_options = nil) ⇒
|
|
122
|
+
<a href="#input-instance_method" title="#input (instance method)">#<strong>input</strong>(wrapper_options = nil) ⇒ String </a>
|
|
119
123
|
|
|
120
124
|
|
|
121
125
|
|
|
@@ -129,7 +133,9 @@
|
|
|
129
133
|
|
|
130
134
|
|
|
131
135
|
|
|
132
|
-
<span class="summary_desc"><div class='inline'
|
|
136
|
+
<span class="summary_desc"><div class='inline'>
|
|
137
|
+
<p>Resolves the anchormodel attribute, builds the collection, and delegates to the underlying SimpleForm input class via <code>super</code>.</p>
|
|
138
|
+
</div></span>
|
|
133
139
|
|
|
134
140
|
</li>
|
|
135
141
|
|
|
@@ -146,7 +152,7 @@
|
|
|
146
152
|
<div class="method_details first">
|
|
147
153
|
<h3 class="signature first" id="input-instance_method">
|
|
148
154
|
|
|
149
|
-
#<strong>input</strong>(wrapper_options = nil) ⇒ <tt>
|
|
155
|
+
#<strong>input</strong>(wrapper_options = nil) ⇒ <tt>String</tt>
|
|
150
156
|
|
|
151
157
|
|
|
152
158
|
|
|
@@ -155,11 +161,66 @@
|
|
|
155
161
|
</h3><div class="docstring">
|
|
156
162
|
<div class="discussion">
|
|
157
163
|
|
|
164
|
+
<p>Resolves the anchormodel attribute, builds the collection, and delegates to the underlying SimpleForm input class via <code>super</code>.</p>
|
|
165
|
+
|
|
158
166
|
|
|
159
167
|
</div>
|
|
160
168
|
</div>
|
|
161
169
|
<div class="tags">
|
|
170
|
+
<p class="tag_title">Parameters:</p>
|
|
171
|
+
<ul class="param">
|
|
172
|
+
|
|
173
|
+
<li>
|
|
174
|
+
|
|
175
|
+
<span class='name'>wrapper_options</span>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
<span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
</li>
|
|
185
|
+
|
|
186
|
+
</ul>
|
|
187
|
+
|
|
188
|
+
<p class="tag_title">Returns:</p>
|
|
189
|
+
<ul class="return">
|
|
190
|
+
|
|
191
|
+
<li>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
—
|
|
199
|
+
<div class='inline'>
|
|
200
|
+
<p>Rendered HTML.</p>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
</li>
|
|
204
|
+
|
|
205
|
+
</ul>
|
|
206
|
+
<p class="tag_title">Raises:</p>
|
|
207
|
+
<ul class="raise">
|
|
208
|
+
|
|
209
|
+
<li>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
<span class='type'>(<tt>RuntimeError</tt>)</span>
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
—
|
|
217
|
+
<div class='inline'>
|
|
218
|
+
<p>if the bound object does not include <span class='object_link'><a href="../../ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span>, or if the attribute does not look like an anchormodel attribute.</p>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
</li>
|
|
162
222
|
|
|
223
|
+
</ul>
|
|
163
224
|
|
|
164
225
|
</div><table class="source_code">
|
|
165
226
|
<tr>
|
|
@@ -167,20 +228,6 @@
|
|
|
167
228
|
<pre class="lines">
|
|
168
229
|
|
|
169
230
|
|
|
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
231
|
19
|
|
185
232
|
20
|
|
186
233
|
21
|
|
@@ -221,10 +268,24 @@
|
|
|
221
268
|
56
|
|
222
269
|
57
|
|
223
270
|
58
|
|
224
|
-
59
|
|
271
|
+
59
|
|
272
|
+
60
|
|
273
|
+
61
|
|
274
|
+
62
|
|
275
|
+
63
|
|
276
|
+
64
|
|
277
|
+
65
|
|
278
|
+
66
|
|
279
|
+
67
|
|
280
|
+
68
|
|
281
|
+
69
|
|
282
|
+
70
|
|
283
|
+
71
|
|
284
|
+
72
|
|
285
|
+
73</pre>
|
|
225
286
|
</td>
|
|
226
287
|
<td>
|
|
227
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb', line
|
|
288
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb', line 19</span>
|
|
228
289
|
|
|
229
290
|
<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>
|
|
230
291
|
<span class='kw'>if</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
@@ -291,7 +352,7 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
|
|
|
291
352
|
</div>
|
|
292
353
|
|
|
293
354
|
<div id="footer">
|
|
294
|
-
Generated on Wed May 13
|
|
355
|
+
Generated on Wed May 13 15:48:24 2026 by
|
|
295
356
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
296
357
|
0.9.28 (ruby-3.3.5).
|
|
297
358
|
</div>
|
|
@@ -83,16 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
</div>
|
|
85
85
|
|
|
86
|
-
<
|
|
87
|
-
<div class="discussion">
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
<div class="tags">
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</div><h2>Defined Under Namespace</h2>
|
|
86
|
+
<h2>Defined Under Namespace</h2>
|
|
96
87
|
<p class="children">
|
|
97
88
|
|
|
98
89
|
|
|
@@ -114,7 +105,7 @@
|
|
|
114
105
|
</div>
|
|
115
106
|
|
|
116
107
|
<div id="footer">
|
|
117
|
-
Generated on Wed May 13
|
|
108
|
+
Generated on Wed May 13 15:48:24 2026 by
|
|
118
109
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
110
|
0.9.28 (ruby-3.3.5).
|
|
120
111
|
</div>
|
|
@@ -83,16 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
</div>
|
|
85
85
|
|
|
86
|
-
<
|
|
87
|
-
<div class="discussion">
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
<div class="tags">
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</div><h2>Defined Under Namespace</h2>
|
|
86
|
+
<h2>Defined Under Namespace</h2>
|
|
96
87
|
<p class="children">
|
|
97
88
|
|
|
98
89
|
|
|
@@ -114,7 +105,7 @@
|
|
|
114
105
|
</div>
|
|
115
106
|
|
|
116
107
|
<div id="footer">
|
|
117
|
-
Generated on Wed May 13
|
|
108
|
+
Generated on Wed May 13 15:48:24 2026 by
|
|
118
109
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
110
|
0.9.28 (ruby-3.3.5).
|
|
120
111
|
</div>
|