anchormodel 0.1.5 → 0.2.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +78 -2
  5. data/VERSION +1 -1
  6. data/anchormodel.gemspec +4 -4
  7. data/doc/Anchormodel/ActiveModelTypeValueSingle.html +113 -31
  8. data/doc/Anchormodel/Attribute.html +109 -9
  9. data/doc/Anchormodel/ModelMixin.html +75 -3
  10. data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +269 -0
  11. data/doc/Anchormodel/SimpleFormInputs/Helpers.html +124 -0
  12. data/doc/Anchormodel/SimpleFormInputs.html +124 -0
  13. data/doc/Anchormodel/Util.html +131 -15
  14. data/doc/Anchormodel/Version.html +3 -3
  15. data/doc/Anchormodel.html +97 -32
  16. data/doc/AnchormodelGenerator.html +3 -3
  17. data/doc/AnchormodelInput.html +140 -0
  18. data/doc/AnchormodelRadioButtonsInput.html +140 -0
  19. data/doc/_index.html +16 -4
  20. data/doc/class_list.html +1 -1
  21. data/doc/file.README.html +77 -5
  22. data/doc/frames.html +1 -1
  23. data/doc/index.html +77 -5
  24. data/doc/method_list.html +62 -6
  25. data/doc/top-level-namespace.html +4 -4
  26. data/lib/anchormodel/active_model_type_value_multi.rb +31 -0
  27. data/lib/anchormodel/active_model_type_value_single.rb +4 -2
  28. data/lib/anchormodel/attribute.rb +7 -1
  29. data/lib/anchormodel/model_mixin.rb +7 -0
  30. data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +23 -0
  31. data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +8 -3
  32. data/lib/anchormodel/util.rb +57 -7
  33. data/lib/anchormodel.rb +7 -0
  34. data/test/active_record_model/user_test.rb +73 -9
  35. data/test/dummy/app/anchormodels/animal.rb +6 -0
  36. data/test/dummy/app/models/user.rb +1 -0
  37. data/test/dummy/db/migrate/20240425182000_add_animals_to_users.rb +5 -0
  38. data/test/dummy/db/schema.rb +2 -1
  39. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0321a1c26ba215c332b2b496cefda3a5a1459f82599dc2655e16368e53af351e
4
- data.tar.gz: 4361b8edc741f1509f460fc579d1f3e3ded9e59f0ae1d8ff623da6bee6502f4b
3
+ metadata.gz: 0f7343b6009976e35fa3354eeabe119ad354dd4f103af1d1440251cf178de989
4
+ data.tar.gz: b971498fc5b0028c2f43994130abf55b6edfb9be0a327113e5cf099911c5ed78
5
5
  SHA512:
6
- metadata.gz: a18303288bcf7aac1a46d6de54f4adc631a8ff535c37a401a39beda41f762cf2cf94d11a266367e80026fefddb3fb0174b826be9f0f5e6fb4e036286e99d4f89
7
- data.tar.gz: 22a389c15f1cc54f9e7fb9b20b9b54683db85cbcbbd16cfc9fb42c900221665d1969c79cbfe8a3f290efaf8a472f1e2d3fed9f050b2c27b2d818abc12c3f0a03
6
+ metadata.gz: a3a0b3e80ea3fa4fdec3fa3ade5ce8536a0e8ff00f17019a291646bc307ec6a84a8c5b12c6e247c8bfad51d6bf80df1bec3114ea9edf9b208537c5db28a1a523
7
+ data.tar.gz: 14af2506a7729e82c7ed664c61a0523e7dcf2e2595c83078986b6a8d590013dcb543b8e6d641f0b742dc23a9f785cd3585286e5066fb10a6a74dc463cd67ac35
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.2.0 (27.04.2024)
2
+
3
+ - Add support for multiple anchormodels (`belongs_to_anchormodels`)
4
+ - Implement YourAnchormodelclass.form_collection
5
+
1
6
  # 0.1.5 (24.04.2024)
2
7
 
3
8
  - Enhance documentation
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anchormodel (0.1.5.edge)
4
+ anchormodel (0.1.6.edge)
5
5
  rails (~> 7.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -223,6 +223,82 @@ If you want to have multiple attributes in the same model pointing to the same A
223
223
 
224
224
  ```ruby
225
225
  # app/models/user.rb
226
- belongs_to_anchormodel :role
227
- belongs_to_anchormodel :secondary_role, Role, model_methods: false
226
+ belongs_to_anchormodel :role
227
+ belongs_to_anchormodel :secondary_role, Role, model_methods: false
228
+ ```
229
+
230
+ # Attaching multiple Anchormodels to an attribute (similar to a has_many collection)
231
+
232
+ Collections of Anchormodels are supported. Assuming that your `User` can have multiple `Role` anchormodels, your code can look as follows:
233
+
234
+ ```ruby
235
+ # app/models/user.rb
236
+ belongs_to_anchormodels :roles
237
+ ```
238
+
239
+ The method is deliberately called `belongs_to...` and not `has_many...` in order to indicate that the key is stored in a column of the model in which you are calling it. The rule of thumb for using a collection of Anchormodels is:
240
+
241
+ - Your column should be of type `string`, just like with the singular `belongs_to_anchormodel`.
242
+ - Anchormodels will be stored in string form, separated by the `,` character
243
+ - When reading the attribute, you will get a `Set`, thus duplicates are avoided.
244
+
245
+ Example usage for a User model with multiple roles as shown above:
246
+
247
+ ```ruby
248
+ u = User.first
249
+ u.roles = %i[moderator admin] # this will replace the user's roles by the two specified
250
+ u.roles # this will return a set of two Role Anchormodel instances, moderator and role
251
+ u.guest! # this will add the role `guest` to the user's roles
252
+ u.guest? # this will query whether the role `guest` is part of the user's roles
253
+ User.moderator # This will return all users that have the moderator role as part of their roles
254
+ ```
255
+
256
+ For modifying a collection of Anchormodels, the following methods are implemented, the first three accepting a String, Symbol or Anchormodel:
257
+
258
+ ```ruby
259
+ u.roles.add(:moderator) # same as u.moderator!
260
+ u.roles << :moderator # alias of add
261
+ u.roles.delete(:moderator)
262
+ u.roles.clear
263
+ ```
264
+
265
+ Note that no other methods of Set are overwritten at this point - if you use any other methods mutating the underlying Set, your changes will not be applied.
266
+
267
+ ## Basic rails form for a collection of Anchormodels
268
+
269
+ ```erb
270
+ <%= form_with(model: user) do |form| %>
271
+ <%# ... %>
272
+ <%= form.collection_select :role, Role.all, :key, :label, multiple: true %>
273
+ <%# ... %>
274
+ <% end %>
275
+ ```
276
+
277
+ If you get an error due to unpermitted params, make sure, you are allowing array-style parameters: `params.require(:user).permit(roles: [])`
278
+
279
+ ## SimpleForm for a collection of Anchormodels
280
+
281
+ Anchormodel's [simple_form](https://github.com/heartcombo/simple_form) support also includes collections of Anchormodels.
282
+
283
+ Just like in the single Anchormodel implementation, a select input can be provided with:
284
+
285
+ ```erb
286
+ <%= simple_form_for user do |f| %>
287
+ <%# ... %>
288
+ <%= f.input :role %>
289
+ <%# ... %>
290
+ <% end %>
291
+ ```
292
+
293
+ The input figures out automatically that it is operating on a collection, so the form code is the same as for a single Anchormodel.
294
+
295
+ However, radio buttons are unsuitable for collections, so use check boxes instead:
296
+
297
+
298
+ ```erb
299
+ <%= simple_form_for user do |f| %>
300
+ <%# ... %>
301
+ <%= f.input :role, as: :anchormodel_check_boxes %>
302
+ <%# ... %>
303
+ <% end %>
228
304
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.2.0
data/anchormodel.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # This file is auto-generated via: 'rake gemspec'.
3
3
 
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: anchormodel 0.1.5 ruby lib
5
+ # stub: anchormodel 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.1.5".freeze
9
+ s.version = "0.2.0".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Sandro Kalbermatter".freeze]
14
- s.date = "2024-04-24"
15
- s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "anchormodel.gemspec".freeze, "bin/rails".freeze, "doc/Anchormodel.html".freeze, "doc/Anchormodel/ActiveModelTypeValue.html".freeze, "doc/Anchormodel/ActiveModelTypeValueSingle.html".freeze, "doc/Anchormodel/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/Util.html".freeze, "doc/Anchormodel/Version.html".freeze, "doc/AnchormodelGenerator.html".freeze, "doc/_index.html".freeze, "doc/class_list.html".freeze, "doc/css/common.css".freeze, "doc/css/full_list.css".freeze, "doc/css/style.css".freeze, "doc/file.README.html".freeze, "doc/file_list.html".freeze, "doc/frames.html".freeze, "doc/index.html".freeze, "doc/js/app.js".freeze, "doc/js/full_list.js".freeze, "doc/js/jquery.js".freeze, "doc/method_list.html".freeze, "doc/top-level-namespace.html".freeze, "lib/anchormodel.rb".freeze, "lib/anchormodel/active_model_type_value_single.rb".freeze, "lib/anchormodel/attribute.rb".freeze, "lib/anchormodel/model_mixin.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_input.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb".freeze, "lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb".freeze, "lib/anchormodel/util.rb".freeze, "lib/anchormodel/version.rb".freeze, "lib/generators/anchormodel/USAGE".freeze, "lib/generators/anchormodel/anchormodel_generator.rb".freeze, "lib/generators/anchormodel/templates/anchormodel.rb.erb".freeze, "logo.svg".freeze, "test/active_record_model/user_test.rb".freeze, "test/dummy/.gitignore".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/anchormodels/locale.rb".freeze, "test/dummy/app/anchormodels/role.rb".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/credentials.yml.enc".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/content_security_policy.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/permissions_policy.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/db/migrate/20230107173151_create_users.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/db/seeds.rb".freeze, "test/dummy/lib/tasks/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/tmp/.keep".freeze, "test/dummy/tmp/pids/.keep".freeze, "test/test_helper.rb".freeze]
14
+ s.date = "2024-04-27"
15
+ s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "anchormodel.gemspec".freeze, "bin/rails".freeze, "doc/Anchormodel.html".freeze, "doc/Anchormodel/ActiveModelTypeValue.html".freeze, "doc/Anchormodel/ActiveModelTypeValueSingle.html".freeze, "doc/Anchormodel/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/SimpleFormInputs.html".freeze, "doc/Anchormodel/SimpleFormInputs/Helpers.html".freeze, "doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html".freeze, "doc/Anchormodel/Util.html".freeze, "doc/Anchormodel/Version.html".freeze, "doc/AnchormodelGenerator.html".freeze, "doc/AnchormodelInput.html".freeze, "doc/AnchormodelRadioButtonsInput.html".freeze, "doc/_index.html".freeze, "doc/class_list.html".freeze, "doc/css/common.css".freeze, "doc/css/full_list.css".freeze, "doc/css/style.css".freeze, "doc/file.README.html".freeze, "doc/file_list.html".freeze, "doc/frames.html".freeze, "doc/index.html".freeze, "doc/js/app.js".freeze, "doc/js/full_list.js".freeze, "doc/js/jquery.js".freeze, "doc/method_list.html".freeze, "doc/top-level-namespace.html".freeze, "lib/anchormodel.rb".freeze, "lib/anchormodel/active_model_type_value_multi.rb".freeze, "lib/anchormodel/active_model_type_value_single.rb".freeze, "lib/anchormodel/attribute.rb".freeze, "lib/anchormodel/model_mixin.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_input.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb".freeze, "lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb".freeze, "lib/anchormodel/util.rb".freeze, "lib/anchormodel/version.rb".freeze, "lib/generators/anchormodel/USAGE".freeze, "lib/generators/anchormodel/anchormodel_generator.rb".freeze, "lib/generators/anchormodel/templates/anchormodel.rb.erb".freeze, "logo.svg".freeze, "test/active_record_model/user_test.rb".freeze, "test/dummy/.gitignore".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/anchormodels/animal.rb".freeze, "test/dummy/app/anchormodels/locale.rb".freeze, "test/dummy/app/anchormodels/role.rb".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/credentials.yml.enc".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/content_security_policy.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/permissions_policy.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/db/migrate/20230107173151_create_users.rb".freeze, "test/dummy/db/migrate/20240425182000_add_animals_to_users.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/db/seeds.rb".freeze, "test/dummy/lib/tasks/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/tmp/.keep".freeze, "test/dummy/tmp/pids/.keep".freeze, "test/test_helper.rb".freeze]
16
16
  s.homepage = "https://github.com/kalsan/anchormodel".freeze
17
17
  s.licenses = ["LGPL-3.0-or-later".freeze]
18
18
  s.required_ruby_version = Gem::Requirement.new(">= 3.0.0".freeze)
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Class: Anchormodel::ActiveModelTypeValueSingle
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.34
10
10
 
11
11
  </title>
12
12
 
@@ -117,11 +117,47 @@
117
117
 
118
118
  </ul>
119
119
 
120
+ </div><div id="subclasses">
121
+ <h2>Direct Known Subclasses</h2>
122
+ <p class="children"><span class='object_link'><a href="ActiveModelTypeValueMulti.html" title="Anchormodel::ActiveModelTypeValueMulti (class)">ActiveModelTypeValueMulti</a></span></p>
120
123
  </div>
121
124
 
122
125
 
123
126
 
124
127
 
128
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
129
+ <ul class="summary">
130
+
131
+ <li class="public ">
132
+ <span class="summary_signature">
133
+
134
+ <a href="#attribute-instance_method" title="#attribute (instance method)">#<strong>attribute</strong> &#x21d2; Object </a>
135
+
136
+
137
+
138
+ </span>
139
+
140
+
141
+
142
+
143
+ <span class="note title readonly">readonly</span>
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+ <span class="summary_desc"><div class='inline'></div></span>
154
+
155
+ </li>
156
+
157
+
158
+ </ul>
159
+
160
+
125
161
 
126
162
 
127
163
 
@@ -150,7 +186,7 @@
150
186
 
151
187
 
152
188
  <span class="summary_desc"><div class='inline'>
153
- <p>This converts an Anchormodel instance to string for DB.</p>
189
+ <p>This converts DB or input to an Anchormodel instance.</p>
154
190
  </div></span>
155
191
 
156
192
  </li>
@@ -244,7 +280,7 @@
244
280
 
245
281
 
246
282
  <span class="summary_desc"><div class='inline'>
247
- <p>This converts DB or input to an Anchormodel instance.</p>
283
+ <p>This converts an Anchormodel instance to string for DB.</p>
248
284
  </div></span>
249
285
 
250
286
  </li>
@@ -305,13 +341,13 @@
305
341
  <pre class="lines">
306
342
 
307
343
 
308
- 3
309
- 4
310
344
  5
311
- 6</pre>
345
+ 6
346
+ 7
347
+ 8</pre>
312
348
  </td>
313
349
  <td>
314
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 3</span>
350
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 5</span>
315
351
 
316
352
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span>
317
353
  <span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
@@ -324,6 +360,52 @@
324
360
 
325
361
  </div>
326
362
 
363
+ <div id="instance_attr_details" class="attr_details">
364
+ <h2>Instance Attribute Details</h2>
365
+
366
+
367
+ <span id=""></span>
368
+ <div class="method_details first">
369
+ <h3 class="signature first" id="attribute-instance_method">
370
+
371
+ #<strong>attribute</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
372
+
373
+
374
+
375
+
376
+
377
+ </h3><div class="docstring">
378
+ <div class="discussion">
379
+
380
+
381
+ </div>
382
+ </div>
383
+ <div class="tags">
384
+
385
+
386
+ </div><table class="source_code">
387
+ <tr>
388
+ <td>
389
+ <pre class="lines">
390
+
391
+
392
+ 3
393
+ 4
394
+ 5</pre>
395
+ </td>
396
+ <td>
397
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 3</span>
398
+
399
+ <span class='kw'>def</span> <span class='id identifier rubyid_attribute'>attribute</span>
400
+ <span class='ivar'>@attribute</span>
401
+ <span class='kw'>end</span></pre>
402
+ </td>
403
+ </tr>
404
+ </table>
405
+ </div>
406
+
407
+ </div>
408
+
327
409
 
328
410
  <div id="instance_method_details" class="method_details_list">
329
411
  <h2>Instance Method Details</h2>
@@ -341,7 +423,7 @@
341
423
  </h3><div class="docstring">
342
424
  <div class="discussion">
343
425
 
344
- <p>This converts an Anchormodel instance to string for DB</p>
426
+ <p>This converts DB or input to an Anchormodel instance</p>
345
427
 
346
428
 
347
429
  </div>
@@ -355,14 +437,14 @@
355
437
  <pre class="lines">
356
438
 
357
439
 
358
- 13
359
- 14
360
440
  15
361
441
  16
362
- 17</pre>
442
+ 17
443
+ 18
444
+ 19</pre>
363
445
  </td>
364
446
  <td>
365
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 13</span>
447
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 15</span>
366
448
 
367
449
  <span class='kw'>def</span> <span class='id identifier rubyid_cast'>cast</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
368
450
  <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_presence'>presence</span>
@@ -411,13 +493,13 @@
411
493
  <pre class="lines">
412
494
 
413
495
 
414
- 48
415
- 49
416
496
  50
417
- 51</pre>
497
+ 51
498
+ 52
499
+ 53</pre>
418
500
  </td>
419
501
  <td>
420
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 48</span>
502
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 50</span>
421
503
 
422
504
  <span class='kw'>def</span> <span class='id identifier rubyid_changed_in_place?'>changed_in_place?</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_old_value'>raw_old_value</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
423
505
  <span class='id identifier rubyid_old_value'>old_value</span> <span class='op'>=</span> <span class='id identifier rubyid_deserialize'>deserialize</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_old_value'>raw_old_value</span><span class='rparen'>)</span>
@@ -465,8 +547,6 @@
465
547
  <pre class="lines">
466
548
 
467
549
 
468
- 37
469
- 38
470
550
  39
471
551
  40
472
552
  41
@@ -474,10 +554,12 @@
474
554
  43
475
555
  44
476
556
  45
477
- 46</pre>
557
+ 46
558
+ 47
559
+ 48</pre>
478
560
  </td>
479
561
  <td>
480
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 37</span>
562
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 39</span>
481
563
 
482
564
  <span class='kw'>def</span> <span class='id identifier rubyid_serializable?'>serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
483
565
  <span class='kw'>return</span> <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span>
@@ -506,7 +588,7 @@
506
588
  </h3><div class="docstring">
507
589
  <div class="discussion">
508
590
 
509
- <p>This converts DB or input to an Anchormodel instance</p>
591
+ <p>This converts an Anchormodel instance to string for DB</p>
510
592
 
511
593
 
512
594
  </div>
@@ -520,8 +602,6 @@
520
602
  <pre class="lines">
521
603
 
522
604
 
523
- 20
524
- 21
525
605
  22
526
606
  23
527
607
  24
@@ -535,10 +615,12 @@
535
615
  32
536
616
  33
537
617
  34
538
- 35</pre>
618
+ 35
619
+ 36
620
+ 37</pre>
539
621
  </td>
540
622
  <td>
541
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 20</span>
623
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 22</span>
542
624
 
543
625
  <span class='kw'>def</span> <span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
544
626
  <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_presence'>presence</span>
@@ -585,12 +667,12 @@
585
667
  <pre class="lines">
586
668
 
587
669
 
588
- 8
589
- 9
590
- 10</pre>
670
+ 10
671
+ 11
672
+ 12</pre>
591
673
  </td>
592
674
  <td>
593
- <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 8</span>
675
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 10</span>
594
676
 
595
677
  <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span>
596
678
  <span class='symbol'>:anchormodel</span>
@@ -605,9 +687,9 @@
605
687
  </div>
606
688
 
607
689
  <div id="footer">
608
- Generated on Wed Apr 24 17:01:46 2024 by
690
+ Generated on Sat Apr 27 10:18:33 2024 by
609
691
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
610
- 0.9.28 (ruby-3.2.2).
692
+ 0.9.34 (ruby-3.2.2).
611
693
  </div>
612
694
 
613
695
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Class: Anchormodel::Attribute
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
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 Wed Apr 24 17:01:46 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.28 (ruby-3.2.2).
601
+ 0.9.34 (ruby-3.2.2).
502
602
  </div>
503
603
 
504
604
  </div>