anchormodel 0.1.5 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile.lock +6 -6
  4. data/README.md +78 -2
  5. data/VERSION +1 -1
  6. data/anchormodel.gemspec +4 -4
  7. data/doc/Anchormodel/ActiveModelTypeValueMulti.html +410 -0
  8. data/doc/Anchormodel/ActiveModelTypeValueSingle.html +113 -31
  9. data/doc/Anchormodel/Attribute.html +109 -9
  10. data/doc/Anchormodel/ModelMixin.html +3 -92
  11. data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +267 -0
  12. data/doc/Anchormodel/SimpleFormInputs/Helpers.html +124 -0
  13. data/doc/Anchormodel/SimpleFormInputs.html +124 -0
  14. data/doc/Anchormodel/Util.html +131 -15
  15. data/doc/Anchormodel/Version.html +3 -3
  16. data/doc/Anchormodel.html +97 -32
  17. data/doc/AnchormodelCheckBoxesInput.html +140 -0
  18. data/doc/AnchormodelGenerator.html +3 -3
  19. data/doc/AnchormodelInput.html +140 -0
  20. data/doc/AnchormodelRadioButtonsInput.html +140 -0
  21. data/doc/_index.html +16 -4
  22. data/doc/class_list.html +1 -1
  23. data/doc/file.README.html +77 -5
  24. data/doc/frames.html +1 -1
  25. data/doc/index.html +77 -5
  26. data/doc/method_list.html +49 -9
  27. data/doc/top-level-namespace.html +4 -4
  28. data/lib/anchormodel/active_model_type_value_multi.rb +31 -0
  29. data/lib/anchormodel/active_model_type_value_single.rb +4 -2
  30. data/lib/anchormodel/attribute.rb +7 -1
  31. data/lib/anchormodel/model_mixin.rb +7 -0
  32. data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +23 -0
  33. data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +7 -3
  34. data/lib/anchormodel/util.rb +57 -7
  35. data/lib/anchormodel.rb +7 -0
  36. data/test/active_record_model/user_test.rb +73 -9
  37. data/test/dummy/app/anchormodels/animal.rb +6 -0
  38. data/test/dummy/app/models/user.rb +1 -0
  39. data/test/dummy/db/migrate/20240425182000_add_animals_to_users.rb +5 -0
  40. data/test/dummy/db/schema.rb +2 -1
  41. metadata +13 -2
@@ -0,0 +1,267 @@
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</pre>
208
+ </td>
209
+ <td>
210
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb', line 5</span>
211
+
212
+ <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>
213
+ <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>
214
+ <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`, \
215
+ 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>
216
+ <span class='kw'>end</span>
217
+
218
+ <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>
219
+ <span class='kw'>unless</span> <span class='id identifier rubyid_am_attr'>am_attr</span>
220
+ <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? \
221
+ 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>
222
+ <span class='kw'>end</span>
223
+ <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>
224
+ <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
225
+ </span>
226
+ <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.
227
+ </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>
228
+ <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>
229
+ <span class='comment'># No selected key override present and a model is present, use the model to find out what to select.
230
+ </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>
231
+ <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>
232
+ <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>
233
+ <span class='kw'>else</span>
234
+ <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>
235
+ <span class='kw'>end</span>
236
+ <span class='kw'>end</span>
237
+
238
+ <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>
239
+ <span class='label'>label_method:</span> <span class='symbol'>:first</span><span class='comma'>,</span>
240
+ <span class='label'>value_method:</span> <span class='symbol'>:second</span><span class='comma'>,</span>
241
+ <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>
242
+ <span class='rparen'>)</span>
243
+
244
+ <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>
245
+
246
+ <span class='id identifier rubyid_before_render_input'>before_render_input</span>
247
+
248
+ <span class='kw'>super</span>
249
+ <span class='kw'>end</span></pre>
250
+ </td>
251
+ </tr>
252
+ </table>
253
+ </div>
254
+
255
+ </div>
256
+
257
+ </div>
258
+
259
+ <div id="footer">
260
+ Generated on Wed May 22 11:24:43 2024 by
261
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
262
+ 0.9.34 (ruby-3.2.2).
263
+ </div>
264
+
265
+ </div>
266
+ </body>
267
+ </html>
@@ -0,0 +1,124 @@
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
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";
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 (H)</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>
41
+ &raquo;
42
+ <span class="title">Helpers</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
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <div class="docstring">
87
+ <div class="discussion">
88
+
89
+
90
+ </div>
91
+ </div>
92
+ <div class="tags">
93
+
94
+
95
+ </div><h2>Defined Under Namespace</h2>
96
+ <p class="children">
97
+
98
+
99
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Helpers/AnchormodelInputsCommon.html" title="Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon (module)">AnchormodelInputsCommon</a></span>
100
+
101
+
102
+
103
+
104
+ </p>
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ </div>
115
+
116
+ <div id="footer">
117
+ Generated on Wed May 22 11:24:43 2024 by
118
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
+ 0.9.34 (ruby-3.2.2).
120
+ </div>
121
+
122
+ </div>
123
+ </body>
124
+ </html>
@@ -0,0 +1,124 @@
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
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";
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="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span>
41
+ &raquo;
42
+ <span class="title">SimpleFormInputs</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
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <div class="docstring">
87
+ <div class="discussion">
88
+
89
+
90
+ </div>
91
+ </div>
92
+ <div class="tags">
93
+
94
+
95
+ </div><h2>Defined Under Namespace</h2>
96
+ <p class="children">
97
+
98
+
99
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="SimpleFormInputs/Helpers.html" title="Anchormodel::SimpleFormInputs::Helpers (module)">Helpers</a></span>
100
+
101
+
102
+
103
+
104
+ </p>
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ </div>
115
+
116
+ <div id="footer">
117
+ Generated on Wed May 22 11:24:43 2024 by
118
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
+ 0.9.34 (ruby-3.2.2).
120
+ </div>
121
+
122
+ </div>
123
+ </body>
124
+ </html>