anchormodel 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07bc0ce1f755bae4c92dfd6fa7c80e33b60ed348482ea8c25a6a1a65b10d8ef0
4
- data.tar.gz: ea624e7f77d9b04bb2affdb86683e5f50cd102357a7a6d8ad3a6d82dfb00c4ab
3
+ metadata.gz: 8dc8f056d1710a491d181aef71c5b576302d21baaf2f0075557f71e467e5f63a
4
+ data.tar.gz: 7b9d36723f5485c18de24450021e7a0822c9a479af99a556b58643fcd4375316
5
5
  SHA512:
6
- metadata.gz: 2b39a0f238bc979f960a81bf9ff117c7be02e74a7bf942e075cd29586120c53f2d8158753db132733b3cb6099faad94e7a076079613711404a7fd69c3a1b1ef9
7
- data.tar.gz: 31e6137480ca09a3d2eb0624c70e43f02494a4c2e7b2ecc4c671f032304d6956d75c8fc53959564447362230ef57ab3519ff741fa27b65377e50982657dcfaa6
6
+ metadata.gz: 0d7f310e1e5ff0a4d310408a792c5794d8f6068a8a8b01f2a650270a3e46a1a3ff7c31a4ed403eb3588f4d378b959906a881f6c03105d5a1165059bfed3a0530
7
+ data.tar.gz: 60f5405f9b8f24e3477e4a37396c45409321da47826f252185f9c255bbbaa18e462243dbfc650ac113a61994a683d701689f9fb81d2bed2912d88242ab6d3136
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.2.5
2
+
3
+ - Fix an issue in combination with the active_type gem, causing virtual models to always read nil on anchormodel attributes
4
+ - When serializing an Anchormodel to json, return the key
5
+
1
6
  # 0.2.4 (06.11.2024)
2
7
 
3
8
  - Implement `YourConstant.first` as a shorthand for `YourConstant.all.first` to avoid Rubocop problems
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
data/anchormodel.gemspec CHANGED
@@ -2,21 +2,21 @@
2
2
  # This file is auto-generated via: 'rake gemspec'.
3
3
 
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: anchormodel 0.2.4 ruby lib
5
+ # stub: anchormodel 0.2.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.2.4".freeze
9
+ s.version = "0.2.5".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-11-06"
14
+ s.date = "2025-02-14"
15
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/ActiveModelTypeValueMulti.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/AnchormodelCheckBoxesInput.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)
19
- s.rubygems_version = "3.5.22".freeze
19
+ s.rubygems_version = "3.6.3".freeze
20
20
  s.summary = "Bringing object-oriented programming to Rails enums".freeze
21
21
 
22
22
  s.specification_version = 4
@@ -400,7 +400,7 @@
400
400
  </div>
401
401
 
402
402
  <div id="footer">
403
- Generated on Wed Nov 6 17:50:34 2024 by
403
+ Generated on Fri Feb 14 13:25:30 2025 by
404
404
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
405
405
  0.9.37 (ruby-3.3.5).
406
406
  </div>
@@ -687,7 +687,7 @@
687
687
  </div>
688
688
 
689
689
  <div id="footer">
690
- Generated on Wed Nov 6 17:50:34 2024 by
690
+ Generated on Fri Feb 14 13:25:30 2025 by
691
691
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
692
692
  0.9.37 (ruby-3.3.5).
693
693
  </div>
@@ -596,7 +596,7 @@
596
596
  </div>
597
597
 
598
598
  <div id="footer">
599
- Generated on Wed Nov 6 17:50:34 2024 by
599
+ Generated on Fri Feb 14 13:25:30 2025 by
600
600
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
601
601
  0.9.37 (ruby-3.3.5).
602
602
  </div>
@@ -273,7 +273,7 @@
273
273
  </div>
274
274
 
275
275
  <div id="footer">
276
- Generated on Wed Nov 6 17:50:34 2024 by
276
+ Generated on Fri Feb 14 13:25:30 2025 by
277
277
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
278
278
  0.9.37 (ruby-3.3.5).
279
279
  </div>
@@ -269,7 +269,7 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
269
269
  </div>
270
270
 
271
271
  <div id="footer">
272
- Generated on Wed Nov 6 17:50:34 2024 by
272
+ Generated on Fri Feb 14 13:25:30 2025 by
273
273
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
274
274
  0.9.37 (ruby-3.3.5).
275
275
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed Nov 6 17:50:34 2024 by
117
+ Generated on Fri Feb 14 13:25:30 2025 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.37 (ruby-3.3.5).
120
120
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed Nov 6 17:50:34 2024 by
117
+ Generated on Fri Feb 14 13:25:30 2025 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.37 (ruby-3.3.5).
120
120
  </div>
@@ -458,7 +458,13 @@
458
458
  139
459
459
  140
460
460
  141
461
- 142</pre>
461
+ 142
462
+ 143
463
+ 144
464
+ 145
465
+ 146
466
+ 147
467
+ 148</pre>
462
468
  </td>
463
469
  <td>
464
470
  <pre class="code"><span class="info file"># File 'lib/anchormodel/util.rb', line 14</span>
@@ -497,7 +503,13 @@
497
503
 
498
504
  <span class='comment'># Overwrite reader to force building anchors at every retrieval
499
505
  </span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span> <span class='kw'>do</span>
500
- <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span><span class='period'>.</span><span class='id identifier rubyid_deserialize'>deserialize</span><span class='lparen'>(</span><span class='id identifier rubyid_read_attribute_before_type_cast'>read_attribute_before_type_cast</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
506
+ <span class='comment'># This patch fixes an issue in combination with the active_type gem, causing virtual models to always read nil on anchormodel attributes.
507
+ </span> <span class='id identifier rubyid_raw_data'>raw_data</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'>ActiveType</span><span class='op'>::</span><span class='const'>Object</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>ActiveType</span><span class='op'>::</span><span class='const'>Object</span><span class='rparen'>)</span>
508
+ <span class='id identifier rubyid_virtual_attributes'>virtual_attributes</span><span class='lbracket'>[</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span>
509
+ <span class='kw'>else</span>
510
+ <span class='id identifier rubyid_read_attribute_before_type_cast'>read_attribute_before_type_cast</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span>
511
+ <span class='kw'>end</span>
512
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span><span class='period'>.</span><span class='id identifier rubyid_deserialize'>deserialize</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_data'>raw_data</span><span class='rparen'>)</span>
501
513
 
502
514
  <span class='comment'># If this attribute holds multiple anchormodels (`belongs_to_anchormodels`), patch the Array before returning in order to implement collection modifiers:
503
515
  </span> <span class='kw'>if</span> <span class='id identifier rubyid_multiple'>multiple</span>
@@ -602,7 +614,7 @@
602
614
  </div>
603
615
 
604
616
  <div id="footer">
605
- Generated on Wed Nov 6 17:50:34 2024 by
617
+ Generated on Fri Feb 14 13:25:30 2025 by
606
618
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
607
619
  0.9.37 (ruby-3.3.5).
608
620
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Wed Nov 6 17:50:34 2024 by
132
+ Generated on Fri Feb 14 13:25:30 2025 by
133
133
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.9.37 (ruby-3.3.5).
135
135
  </div>
data/doc/Anchormodel.html CHANGED
@@ -344,6 +344,28 @@
344
344
 
345
345
 
346
346
 
347
+ <span class="summary_desc"><div class='inline'></div></span>
348
+
349
+ </li>
350
+
351
+
352
+ <li class="public ">
353
+ <span class="summary_signature">
354
+
355
+ <a href="#as_json-instance_method" title="#as_json (instance method)">#<strong>as_json</strong> &#x21d2; Object </a>
356
+
357
+
358
+
359
+ </span>
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
347
369
  <span class="summary_desc"><div class='inline'></div></span>
348
370
 
349
371
  </li>
@@ -938,6 +960,45 @@
938
960
  </td>
939
961
  </tr>
940
962
  </table>
963
+ </div>
964
+
965
+ <div class="method_details ">
966
+ <h3 class="signature " id="as_json-instance_method">
967
+
968
+ #<strong>as_json</strong> &#x21d2; <tt>Object</tt>
969
+
970
+
971
+
972
+
973
+
974
+ </h3><div class="docstring">
975
+ <div class="discussion">
976
+
977
+
978
+ </div>
979
+ </div>
980
+ <div class="tags">
981
+
982
+
983
+ </div><table class="source_code">
984
+ <tr>
985
+ <td>
986
+ <pre class="lines">
987
+
988
+
989
+ 89
990
+ 90
991
+ 91</pre>
992
+ </td>
993
+ <td>
994
+ <pre class="code"><span class="info file"># File 'lib/anchormodel.rb', line 89</span>
995
+
996
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span>
997
+ <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
998
+ <span class='kw'>end</span></pre>
999
+ </td>
1000
+ </tr>
1001
+ </table>
941
1002
  </div>
942
1003
 
943
1004
  <div class="method_details ">
@@ -1064,7 +1125,7 @@
1064
1125
  </div>
1065
1126
 
1066
1127
  <div id="footer">
1067
- Generated on Wed Nov 6 17:50:34 2024 by
1128
+ Generated on Fri Feb 14 13:25:30 2025 by
1068
1129
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1069
1130
  0.9.37 (ruby-3.3.5).
1070
1131
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed Nov 6 17:50:34 2024 by
133
+ Generated on Fri Feb 14 13:25:30 2025 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.37 (ruby-3.3.5).
136
136
  </div>
@@ -191,7 +191,7 @@
191
191
  </div>
192
192
 
193
193
  <div id="footer">
194
- Generated on Wed Nov 6 17:50:34 2024 by
194
+ Generated on Fri Feb 14 13:25:30 2025 by
195
195
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
196
196
  0.9.37 (ruby-3.3.5).
197
197
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed Nov 6 17:50:34 2024 by
133
+ Generated on Fri Feb 14 13:25:30 2025 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.37 (ruby-3.3.5).
136
136
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed Nov 6 17:50:34 2024 by
133
+ Generated on Fri Feb 14 13:25:30 2025 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.37 (ruby-3.3.5).
136
136
  </div>
data/doc/_index.html CHANGED
@@ -220,7 +220,7 @@
220
220
  </div>
221
221
 
222
222
  <div id="footer">
223
- Generated on Wed Nov 6 17:50:33 2024 by
223
+ Generated on Fri Feb 14 13:25:30 2025 by
224
224
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
225
225
  0.9.37 (ruby-3.3.5).
226
226
  </div>
data/doc/file.README.html CHANGED
@@ -339,7 +339,7 @@
339
339
  </div></div>
340
340
 
341
341
  <div id="footer">
342
- Generated on Wed Nov 6 17:50:34 2024 by
342
+ Generated on Fri Feb 14 13:25:30 2025 by
343
343
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
344
344
  0.9.37 (ruby-3.3.5).
345
345
  </div>
data/doc/index.html CHANGED
@@ -339,7 +339,7 @@
339
339
  </div></div>
340
340
 
341
341
  <div id="footer">
342
- Generated on Wed Nov 6 17:50:34 2024 by
342
+ Generated on Fri Feb 14 13:25:30 2025 by
343
343
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
344
344
  0.9.37 (ruby-3.3.5).
345
345
  </div>
data/doc/method_list.html CHANGED
@@ -80,6 +80,14 @@
80
80
 
81
81
 
82
82
  <li class="odd ">
83
+ <div class="item">
84
+ <span class='object_link'><a href="Anchormodel.html#as_json-instance_method" title="Anchormodel#as_json (method)">#as_json</a></span>
85
+ <small>Anchormodel</small>
86
+ </div>
87
+ </li>
88
+
89
+
90
+ <li class="even ">
83
91
  <div class="item">
84
92
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#attribute-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#attribute (method)">#attribute</a></span>
85
93
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -87,7 +95,7 @@
87
95
  </li>
88
96
 
89
97
 
90
- <li class="even ">
98
+ <li class="odd ">
91
99
  <div class="item">
92
100
  <span class='object_link'><a href="Anchormodel/Attribute.html#attribute_name-instance_method" title="Anchormodel::Attribute#attribute_name (method)">#attribute_name</a></span>
93
101
  <small>Anchormodel::Attribute</small>
@@ -95,7 +103,7 @@
95
103
  </li>
96
104
 
97
105
 
98
- <li class="odd ">
106
+ <li class="even ">
99
107
  <div class="item">
100
108
  <span class='object_link'><a href="Anchormodel/ModelMixin.html#belongs_to_anchormodel-class_method" title="Anchormodel::ModelMixin.belongs_to_anchormodel (method)">belongs_to_anchormodel</a></span>
101
109
  <small>Anchormodel::ModelMixin</small>
@@ -103,7 +111,7 @@
103
111
  </li>
104
112
 
105
113
 
106
- <li class="even ">
114
+ <li class="odd ">
107
115
  <div class="item">
108
116
  <span class='object_link'><a href="Anchormodel/ModelMixin.html#belongs_to_anchormodels-class_method" title="Anchormodel::ModelMixin.belongs_to_anchormodels (method)">belongs_to_anchormodels</a></span>
109
117
  <small>Anchormodel::ModelMixin</small>
@@ -111,7 +119,7 @@
111
119
  </li>
112
120
 
113
121
 
114
- <li class="odd ">
122
+ <li class="even ">
115
123
  <div class="item">
116
124
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueMulti.html#cast-instance_method" title="Anchormodel::ActiveModelTypeValueMulti#cast (method)">#cast</a></span>
117
125
  <small>Anchormodel::ActiveModelTypeValueMulti</small>
@@ -119,7 +127,7 @@
119
127
  </li>
120
128
 
121
129
 
122
- <li class="even ">
130
+ <li class="odd ">
123
131
  <div class="item">
124
132
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#cast-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#cast (method)">#cast</a></span>
125
133
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -127,7 +135,7 @@
127
135
  </li>
128
136
 
129
137
 
130
- <li class="odd ">
138
+ <li class="even ">
131
139
  <div class="item">
132
140
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#changed_in_place%3F-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#changed_in_place? (method)">#changed_in_place?</a></span>
133
141
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -135,7 +143,7 @@
135
143
  </li>
136
144
 
137
145
 
138
- <li class="even ">
146
+ <li class="odd ">
139
147
  <div class="item">
140
148
  <span class='object_link'><a href="Anchormodel.html#find-class_method" title="Anchormodel.find (method)">find</a></span>
141
149
  <small>Anchormodel</small>
@@ -143,7 +151,7 @@
143
151
  </li>
144
152
 
145
153
 
146
- <li class="odd ">
154
+ <li class="even ">
147
155
  <div class="item">
148
156
  <span class='object_link'><a href="Anchormodel.html#first-class_method" title="Anchormodel.first (method)">first</a></span>
149
157
  <small>Anchormodel</small>
@@ -151,7 +159,7 @@
151
159
  </li>
152
160
 
153
161
 
154
- <li class="even ">
162
+ <li class="odd ">
155
163
  <div class="item">
156
164
  <span class='object_link'><a href="Anchormodel.html#form_collection-class_method" title="Anchormodel.form_collection (method)">form_collection</a></span>
157
165
  <small>Anchormodel</small>
@@ -159,7 +167,7 @@
159
167
  </li>
160
168
 
161
169
 
162
- <li class="odd ">
170
+ <li class="even ">
163
171
  <div class="item">
164
172
  <span class='object_link'><a href="Anchormodel.html#index-instance_method" title="Anchormodel#index (method)">#index</a></span>
165
173
  <small>Anchormodel</small>
@@ -167,7 +175,7 @@
167
175
  </li>
168
176
 
169
177
 
170
- <li class="even ">
178
+ <li class="odd ">
171
179
  <div class="item">
172
180
  <span class='object_link'><a href="Anchormodel.html#initialize-instance_method" title="Anchormodel#initialize (method)">#initialize</a></span>
173
181
  <small>Anchormodel</small>
@@ -175,7 +183,7 @@
175
183
  </li>
176
184
 
177
185
 
178
- <li class="odd ">
186
+ <li class="even ">
179
187
  <div class="item">
180
188
  <span class='object_link'><a href="Anchormodel/Attribute.html#initialize-instance_method" title="Anchormodel::Attribute#initialize (method)">#initialize</a></span>
181
189
  <small>Anchormodel::Attribute</small>
@@ -183,7 +191,7 @@
183
191
  </li>
184
192
 
185
193
 
186
- <li class="even ">
194
+ <li class="odd ">
187
195
  <div class="item">
188
196
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#initialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#initialize (method)">#initialize</a></span>
189
197
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -191,7 +199,7 @@
191
199
  </li>
192
200
 
193
201
 
194
- <li class="odd ">
202
+ <li class="even ">
195
203
  <div class="item">
196
204
  <span class='object_link'><a href="Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html#input-instance_method" title="Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon#input (method)">#input</a></span>
197
205
  <small>Anchormodel::SimpleFormInputs::Helpers::AnchormodelInputsCommon</small>
@@ -199,7 +207,7 @@
199
207
  </li>
200
208
 
201
209
 
202
- <li class="even ">
210
+ <li class="odd ">
203
211
  <div class="item">
204
212
  <span class='object_link'><a href="Anchormodel.html#inspect-instance_method" title="Anchormodel#inspect (method)">#inspect</a></span>
205
213
  <small>Anchormodel</small>
@@ -207,7 +215,7 @@
207
215
  </li>
208
216
 
209
217
 
210
- <li class="odd ">
218
+ <li class="even ">
211
219
  <div class="item">
212
220
  <span class='object_link'><a href="Anchormodel/Util.html#install_methods_in_model-class_method" title="Anchormodel::Util.install_methods_in_model (method)">install_methods_in_model</a></span>
213
221
  <small>Anchormodel::Util</small>
@@ -215,7 +223,7 @@
215
223
  </li>
216
224
 
217
225
 
218
- <li class="even ">
226
+ <li class="odd ">
219
227
  <div class="item">
220
228
  <span class='object_link'><a href="Anchormodel.html#key-instance_method" title="Anchormodel#key (method)">#key</a></span>
221
229
  <small>Anchormodel</small>
@@ -223,7 +231,7 @@
223
231
  </li>
224
232
 
225
233
 
226
- <li class="odd ">
234
+ <li class="even ">
227
235
  <div class="item">
228
236
  <span class='object_link'><a href="Anchormodel.html#label-instance_method" title="Anchormodel#label (method)">#label</a></span>
229
237
  <small>Anchormodel</small>
@@ -231,7 +239,7 @@
231
239
  </li>
232
240
 
233
241
 
234
- <li class="even ">
242
+ <li class="odd ">
235
243
  <div class="item">
236
244
  <span class='object_link'><a href="Anchormodel/Attribute.html#multiple%3F-instance_method" title="Anchormodel::Attribute#multiple? (method)">#multiple?</a></span>
237
245
  <small>Anchormodel::Attribute</small>
@@ -239,7 +247,7 @@
239
247
  </li>
240
248
 
241
249
 
242
- <li class="odd ">
250
+ <li class="even ">
243
251
  <div class="item">
244
252
  <span class='object_link'><a href="Anchormodel/Attribute.html#optional-instance_method" title="Anchormodel::Attribute#optional (method)">#optional</a></span>
245
253
  <small>Anchormodel::Attribute</small>
@@ -247,7 +255,7 @@
247
255
  </li>
248
256
 
249
257
 
250
- <li class="even ">
258
+ <li class="odd ">
251
259
  <div class="item">
252
260
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueMulti.html#serializable%3F-instance_method" title="Anchormodel::ActiveModelTypeValueMulti#serializable? (method)">#serializable?</a></span>
253
261
  <small>Anchormodel::ActiveModelTypeValueMulti</small>
@@ -255,7 +263,7 @@
255
263
  </li>
256
264
 
257
265
 
258
- <li class="odd ">
266
+ <li class="even ">
259
267
  <div class="item">
260
268
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#serializable%3F-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serializable? (method)">#serializable?</a></span>
261
269
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -263,7 +271,7 @@
263
271
  </li>
264
272
 
265
273
 
266
- <li class="even ">
274
+ <li class="odd ">
267
275
  <div class="item">
268
276
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueMulti.html#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueMulti#serialize (method)">#serialize</a></span>
269
277
  <small>Anchormodel::ActiveModelTypeValueMulti</small>
@@ -271,7 +279,7 @@
271
279
  </li>
272
280
 
273
281
 
274
- <li class="odd ">
282
+ <li class="even ">
275
283
  <div class="item">
276
284
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serialize (method)">#serialize</a></span>
277
285
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -279,7 +287,7 @@
279
287
  </li>
280
288
 
281
289
 
282
- <li class="even ">
290
+ <li class="odd ">
283
291
  <div class="item">
284
292
  <span class='object_link'><a href="Anchormodel.html#setup!-class_method" title="Anchormodel.setup! (method)">setup!</a></span>
285
293
  <small>Anchormodel</small>
@@ -287,7 +295,7 @@
287
295
  </li>
288
296
 
289
297
 
290
- <li class="odd ">
298
+ <li class="even ">
291
299
  <div class="item">
292
300
  <span class='object_link'><a href="Anchormodel.html#to_s-instance_method" title="Anchormodel#to_s (method)">#to_s</a></span>
293
301
  <small>Anchormodel</small>
@@ -295,7 +303,7 @@
295
303
  </li>
296
304
 
297
305
 
298
- <li class="even ">
306
+ <li class="odd ">
299
307
  <div class="item">
300
308
  <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#type-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#type (method)">#type</a></span>
301
309
  <small>Anchormodel::ActiveModelTypeValueSingle</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Wed Nov 6 17:50:34 2024 by
103
+ Generated on Fri Feb 14 13:25:30 2025 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.37 (ruby-3.3.5).
106
106
  </div>
@@ -45,7 +45,13 @@ module Anchormodel::Util
45
45
 
46
46
  # Overwrite reader to force building anchors at every retrieval
47
47
  model_class.define_method(attribute_name.to_s) do
48
- result = active_model_type_value.deserialize(read_attribute_before_type_cast(attribute_name))
48
+ # This patch fixes an issue in combination with the active_type gem, causing virtual models to always read nil on anchormodel attributes.
49
+ raw_data = if defined?(ActiveType::Object) && is_a?(ActiveType::Object)
50
+ virtual_attributes[attribute_name.to_s]
51
+ else
52
+ read_attribute_before_type_cast(attribute_name)
53
+ end
54
+ result = active_model_type_value.deserialize(raw_data)
49
55
 
50
56
  # If this attribute holds multiple anchormodels (`belongs_to_anchormodels`), patch the Array before returning in order to implement collection modifiers:
51
57
  if multiple
data/lib/anchormodel.rb CHANGED
@@ -85,6 +85,10 @@ class Anchormodel
85
85
  def to_s
86
86
  inspect
87
87
  end
88
+
89
+ def as_json
90
+ key.to_s
91
+ end
88
92
  end
89
93
 
90
94
  require 'anchormodel/util'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchormodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-06 00:00:00.000000000 Z
10
+ date: 2025-02-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -150,8 +149,6 @@ dependencies:
150
149
  - - "~>"
151
150
  - !ruby/object:Gem::Version
152
151
  version: 1.6.0
153
- description:
154
- email:
155
152
  executables: []
156
153
  extensions: []
157
154
  extra_rdoc_files: []
@@ -252,7 +249,6 @@ homepage: https://github.com/kalsan/anchormodel
252
249
  licenses:
253
250
  - LGPL-3.0-or-later
254
251
  metadata: {}
255
- post_install_message:
256
252
  rdoc_options: []
257
253
  require_paths:
258
254
  - lib
@@ -267,8 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
263
  - !ruby/object:Gem::Version
268
264
  version: '0'
269
265
  requirements: []
270
- rubygems_version: 3.5.22
271
- signing_key:
266
+ rubygems_version: 3.6.3
272
267
  specification_version: 4
273
268
  summary: Bringing object-oriented programming to Rails enums
274
269
  test_files: []