anchormodel 0.3.0 → 0.3.1
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/.gitignore +3 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +8 -8
- data/VERSION +1 -1
- data/anchormodel.gemspec +3 -3
- data/doc/Anchormodel/ActiveModelTypeValueMulti.html +1 -1
- data/doc/Anchormodel/ActiveModelTypeValueSingle.html +16 -52
- data/doc/Anchormodel/Attribute.html +1 -1
- data/doc/Anchormodel/ModelMixin.html +1 -1
- data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +1 -1
- data/doc/Anchormodel/SimpleFormInputs/Helpers.html +1 -1
- data/doc/Anchormodel/SimpleFormInputs.html +1 -1
- data/doc/Anchormodel/Util.html +1 -1
- data/doc/Anchormodel/Version.html +1 -1
- data/doc/Anchormodel.html +1 -1
- data/doc/AnchormodelCheckBoxesInput.html +1 -1
- data/doc/AnchormodelGenerator.html +1 -1
- data/doc/AnchormodelInput.html +1 -1
- data/doc/AnchormodelRadioButtonsInput.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/anchormodel/active_model_type_value_single.rb +19 -9
- data/test/active_record_model/user_test.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96363c644701666a3392626bef0c55f86ae83e7761c4b50cbf543b6dc89d036e
|
|
4
|
+
data.tar.gz: 1b35c56261e01962b52fdc7420f5f3c4a5a9976de48fc85021c5a107a75e5acf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcb23e9e6e9faa80f1d5b9516a187ef29f0b05ffed2b39e9ecb027e69f014ddd292c6bd92ef08be6fdebfb0e5246a0e7537375969ef08d3b034bf68ce5612132
|
|
7
|
+
data.tar.gz: 44892a2758b72039713326978eaa96d46fc360a23b0b6f72fbabc270af889dc16cf8b44112f91d3cd527c7ab95d70d18a0ace1ad82b5ed82be8505effd68b6f7
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
anchormodel (0.
|
|
4
|
+
anchormodel (0.3.1.edge)
|
|
5
5
|
rails (>= 7.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -87,7 +87,7 @@ GEM
|
|
|
87
87
|
concurrent-ruby (~> 1.0)
|
|
88
88
|
json (2.6.3)
|
|
89
89
|
logger (1.7.0)
|
|
90
|
-
loofah (2.25.
|
|
90
|
+
loofah (2.25.1)
|
|
91
91
|
crass (~> 1.0.2)
|
|
92
92
|
nokogiri (>= 1.12.0)
|
|
93
93
|
mail (2.9.0)
|
|
@@ -106,7 +106,7 @@ GEM
|
|
|
106
106
|
builder
|
|
107
107
|
minitest (>= 5.0)
|
|
108
108
|
ruby-progressbar
|
|
109
|
-
net-imap (0.6.
|
|
109
|
+
net-imap (0.6.4)
|
|
110
110
|
date
|
|
111
111
|
net-protocol
|
|
112
112
|
net-pop (0.1.2)
|
|
@@ -116,7 +116,7 @@ GEM
|
|
|
116
116
|
net-smtp (0.5.1)
|
|
117
117
|
net-protocol
|
|
118
118
|
nio4r (2.7.5)
|
|
119
|
-
nokogiri (1.19.
|
|
119
|
+
nokogiri (1.19.3-x86_64-linux-gnu)
|
|
120
120
|
racc (~> 1.4)
|
|
121
121
|
parallel (1.22.1)
|
|
122
122
|
parser (3.2.0.0)
|
|
@@ -146,8 +146,8 @@ GEM
|
|
|
146
146
|
activesupport (>= 5.0.0)
|
|
147
147
|
minitest
|
|
148
148
|
nokogiri (>= 1.6)
|
|
149
|
-
rails-html-sanitizer (1.
|
|
150
|
-
loofah (~> 2.
|
|
149
|
+
rails-html-sanitizer (1.7.0)
|
|
150
|
+
loofah (~> 2.25)
|
|
151
151
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
152
152
|
railties (7.0.4)
|
|
153
153
|
actionpack (= 7.0.4)
|
|
@@ -180,7 +180,7 @@ GEM
|
|
|
180
180
|
sqlite3 (1.6.0)
|
|
181
181
|
mini_portile2 (~> 2.8.0)
|
|
182
182
|
thor (1.5.0)
|
|
183
|
-
timeout (0.6.
|
|
183
|
+
timeout (0.6.1)
|
|
184
184
|
tzinfo (2.0.5)
|
|
185
185
|
concurrent-ruby (~> 1.0)
|
|
186
186
|
unicode-display_width (2.4.2)
|
|
@@ -193,7 +193,7 @@ GEM
|
|
|
193
193
|
webrick (~> 1.7.0)
|
|
194
194
|
yard-activesupport-concern (0.0.1)
|
|
195
195
|
yard (>= 0.8)
|
|
196
|
-
zeitwerk (2.7.
|
|
196
|
+
zeitwerk (2.7.5)
|
|
197
197
|
|
|
198
198
|
PLATFORMS
|
|
199
199
|
x86_64-linux
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.1
|
data/anchormodel.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# This file is auto-generated via: 'rake gemspec'.
|
|
3
3
|
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: anchormodel 0.3.
|
|
5
|
+
# stub: anchormodel 0.3.1 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "anchormodel".freeze
|
|
9
|
-
s.version = "0.3.
|
|
9
|
+
s.version = "0.3.1".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]
|
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
|
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 = "4.0.
|
|
19
|
+
s.rubygems_version = "4.0.11".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
|
|
403
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
404
404
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
405
405
|
0.9.28 (ruby-3.3.5).
|
|
406
406
|
</div>
|
|
@@ -493,13 +493,13 @@
|
|
|
493
493
|
<pre class="lines">
|
|
494
494
|
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
496
|
+
32
|
|
497
|
+
33
|
|
498
|
+
34
|
|
499
|
+
35</pre>
|
|
500
500
|
</td>
|
|
501
501
|
<td>
|
|
502
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 32</span>
|
|
503
503
|
|
|
504
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>
|
|
505
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>
|
|
@@ -547,29 +547,17 @@
|
|
|
547
547
|
<pre class="lines">
|
|
548
548
|
|
|
549
549
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
43
|
|
555
|
-
44
|
|
556
|
-
45
|
|
557
|
-
46
|
|
558
|
-
47
|
|
559
|
-
48</pre>
|
|
550
|
+
27
|
|
551
|
+
28
|
|
552
|
+
29
|
|
553
|
+
30</pre>
|
|
560
554
|
</td>
|
|
561
555
|
<td>
|
|
562
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
556
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 27</span>
|
|
563
557
|
|
|
564
558
|
<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>
|
|
565
|
-
<span class='kw'>return</span> <span class='kw'>
|
|
566
|
-
|
|
567
|
-
<span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_valid_keys'>valid_keys</span><span class='period'>.</span><span class='id identifier rubyid_exclude?'>exclude?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span>
|
|
568
|
-
<span class='kw'>when</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
|
569
|
-
<span class='kw'>true</span>
|
|
570
|
-
<span class='kw'>else</span>
|
|
571
|
-
<span class='kw'>false</span>
|
|
572
|
-
<span class='kw'>end</span>
|
|
559
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_scalar_serializable?'>scalar_serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
|
560
|
+
<span class='id identifier rubyid_scalar_serializable?'>scalar_serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
573
561
|
<span class='kw'>end</span></pre>
|
|
574
562
|
</td>
|
|
575
563
|
</tr>
|
|
@@ -605,38 +593,14 @@
|
|
|
605
593
|
22
|
|
606
594
|
23
|
|
607
595
|
24
|
|
608
|
-
25
|
|
609
|
-
26
|
|
610
|
-
27
|
|
611
|
-
28
|
|
612
|
-
29
|
|
613
|
-
30
|
|
614
|
-
31
|
|
615
|
-
32
|
|
616
|
-
33
|
|
617
|
-
34
|
|
618
|
-
35
|
|
619
|
-
36
|
|
620
|
-
37</pre>
|
|
596
|
+
25</pre>
|
|
621
597
|
</td>
|
|
622
598
|
<td>
|
|
623
599
|
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 22</span>
|
|
624
600
|
|
|
625
601
|
<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>
|
|
626
|
-
<span class='id identifier rubyid_value'>value</span> <span class='op'
|
|
627
|
-
<span class='
|
|
628
|
-
<span class='kw'>when</span> <span class='const'>Symbol</span><span class='comma'>,</span> <span class='const'>String</span>
|
|
629
|
-
<span class='kw'>unless</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_valid_keys'>valid_keys</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span>
|
|
630
|
-
<span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Attempt to set </span><span class='embexpr_beg'>#{</span><span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to unsupported key </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
|
631
|
-
<span class='kw'>end</span>
|
|
632
|
-
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
|
633
|
-
<span class='kw'>when</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
|
634
|
-
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
|
635
|
-
<span class='kw'>when</span> <span class='kw'>nil</span>
|
|
636
|
-
<span class='kw'>nil</span>
|
|
637
|
-
<span class='kw'>else</span>
|
|
638
|
-
<span class='id identifier rubyid_fail'>fail</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Attempt to set </span><span class='embexpr_beg'>#{</span><span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to unsupported type </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
639
|
-
<span class='kw'>end</span>
|
|
602
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_serialize_scalar'>serialize_scalar</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
|
603
|
+
<span class='id identifier rubyid_serialize_scalar'>serialize_scalar</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
640
604
|
<span class='kw'>end</span></pre>
|
|
641
605
|
</td>
|
|
642
606
|
</tr>
|
|
@@ -687,7 +651,7 @@
|
|
|
687
651
|
</div>
|
|
688
652
|
|
|
689
653
|
<div id="footer">
|
|
690
|
-
Generated on
|
|
654
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
691
655
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
692
656
|
0.9.28 (ruby-3.3.5).
|
|
693
657
|
</div>
|
|
@@ -596,7 +596,7 @@
|
|
|
596
596
|
</div>
|
|
597
597
|
|
|
598
598
|
<div id="footer">
|
|
599
|
-
Generated on
|
|
599
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
600
600
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
601
601
|
0.9.28 (ruby-3.3.5).
|
|
602
602
|
</div>
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
</div>
|
|
274
274
|
|
|
275
275
|
<div id="footer">
|
|
276
|
-
Generated on
|
|
276
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
277
277
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
278
278
|
0.9.28 (ruby-3.3.5).
|
|
279
279
|
</div>
|
|
@@ -291,7 +291,7 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
|
|
|
291
291
|
</div>
|
|
292
292
|
|
|
293
293
|
<div id="footer">
|
|
294
|
-
Generated on
|
|
294
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
295
295
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
296
296
|
0.9.28 (ruby-3.3.5).
|
|
297
297
|
</div>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div id="footer">
|
|
117
|
-
Generated on
|
|
117
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
118
118
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
119
|
0.9.28 (ruby-3.3.5).
|
|
120
120
|
</div>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div id="footer">
|
|
117
|
-
Generated on
|
|
117
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
118
118
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
119
|
0.9.28 (ruby-3.3.5).
|
|
120
120
|
</div>
|
data/doc/Anchormodel/Util.html
CHANGED
|
@@ -614,7 +614,7 @@
|
|
|
614
614
|
</div>
|
|
615
615
|
|
|
616
616
|
<div id="footer">
|
|
617
|
-
Generated on
|
|
617
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
618
618
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
619
619
|
0.9.28 (ruby-3.3.5).
|
|
620
620
|
</div>
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
</div>
|
|
130
130
|
|
|
131
131
|
<div id="footer">
|
|
132
|
-
Generated on
|
|
132
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
133
133
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
134
134
|
0.9.28 (ruby-3.3.5).
|
|
135
135
|
</div>
|
data/doc/Anchormodel.html
CHANGED
|
@@ -1127,7 +1127,7 @@
|
|
|
1127
1127
|
</div>
|
|
1128
1128
|
|
|
1129
1129
|
<div id="footer">
|
|
1130
|
-
Generated on
|
|
1130
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
1131
1131
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1132
1132
|
0.9.28 (ruby-3.3.5).
|
|
1133
1133
|
</div>
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
</div>
|
|
131
131
|
|
|
132
132
|
<div id="footer">
|
|
133
|
-
Generated on
|
|
133
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
134
134
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
135
135
|
0.9.28 (ruby-3.3.5).
|
|
136
136
|
</div>
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
</div>
|
|
192
192
|
|
|
193
193
|
<div id="footer">
|
|
194
|
-
Generated on
|
|
194
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
195
195
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
196
196
|
0.9.28 (ruby-3.3.5).
|
|
197
197
|
</div>
|
data/doc/AnchormodelInput.html
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
</div>
|
|
131
131
|
|
|
132
132
|
<div id="footer">
|
|
133
|
-
Generated on
|
|
133
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
134
134
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
135
135
|
0.9.28 (ruby-3.3.5).
|
|
136
136
|
</div>
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
</div>
|
|
131
131
|
|
|
132
132
|
<div id="footer">
|
|
133
|
-
Generated on
|
|
133
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
134
134
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
135
135
|
0.9.28 (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
|
|
223
|
+
Generated on Wed May 13 11:46:09 2026 by
|
|
224
224
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
225
225
|
0.9.28 (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
|
|
342
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
343
343
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
344
344
|
0.9.28 (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
|
|
342
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
343
343
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
344
344
|
0.9.28 (ruby-3.3.5).
|
|
345
345
|
</div>
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
</div>
|
|
101
101
|
|
|
102
102
|
<div id="footer">
|
|
103
|
-
Generated on
|
|
103
|
+
Generated on Wed May 13 11:46:10 2026 by
|
|
104
104
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
105
105
|
0.9.28 (ruby-3.3.5).
|
|
106
106
|
</div>
|
|
@@ -20,6 +20,23 @@ class Anchormodel::ActiveModelTypeValueSingle < ActiveModel::Type::Value
|
|
|
20
20
|
|
|
21
21
|
# This converts an Anchormodel instance to string for DB
|
|
22
22
|
def serialize(value)
|
|
23
|
+
return value.map { |v| serialize_scalar(v) } if value.is_a?(Array)
|
|
24
|
+
serialize_scalar(value)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def serializable?(value)
|
|
28
|
+
return value.all? { |v| scalar_serializable?(v) } if value.is_a?(Array)
|
|
29
|
+
scalar_serializable?(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def changed_in_place?(raw_old_value, value)
|
|
33
|
+
old_value = deserialize(raw_old_value)
|
|
34
|
+
old_value != value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def serialize_scalar(value)
|
|
23
40
|
value = value.presence
|
|
24
41
|
return case value
|
|
25
42
|
when Symbol, String
|
|
@@ -36,19 +53,12 @@ class Anchormodel::ActiveModelTypeValueSingle < ActiveModel::Type::Value
|
|
|
36
53
|
end
|
|
37
54
|
end
|
|
38
55
|
|
|
39
|
-
def
|
|
56
|
+
def scalar_serializable?(value)
|
|
40
57
|
return case value
|
|
41
|
-
when Symbol, String
|
|
42
|
-
@attribute.anchormodel_class.valid_keys.exclude?(value.to_sym)
|
|
43
|
-
when nil, @attribute.anchormodel_class
|
|
58
|
+
when Symbol, String, nil, @attribute.anchormodel_class
|
|
44
59
|
true
|
|
45
60
|
else
|
|
46
61
|
false
|
|
47
62
|
end
|
|
48
63
|
end
|
|
49
|
-
|
|
50
|
-
def changed_in_place?(raw_old_value, value)
|
|
51
|
-
old_value = deserialize(raw_old_value)
|
|
52
|
-
old_value != value
|
|
53
|
-
end
|
|
54
64
|
end
|
|
@@ -86,6 +86,45 @@ class UserTest < Minitest::Test
|
|
|
86
86
|
assert_equal 0, User.guest.count
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
# Regression: `where(anchormodel_col: %w[a b])` used to collapse to `IN (NULL)`
|
|
90
|
+
# because Single#serialize lacked Array handling. See memory `array-where-collapses-to-null`.
|
|
91
|
+
def test_where_with_array_of_keys
|
|
92
|
+
User.create!(role: :admin, locale: :en)
|
|
93
|
+
User.create!(role: :moderator, locale: :en)
|
|
94
|
+
User.create!(role: :guest, locale: :en)
|
|
95
|
+
|
|
96
|
+
sql = User.where(role: %w[admin moderator]).to_sql
|
|
97
|
+
assert_match(/admin/, sql)
|
|
98
|
+
assert_match(/moderator/, sql)
|
|
99
|
+
refute_match(/IN \(NULL\)/i, sql) # rubocop:disable Rails/RefuteMethods
|
|
100
|
+
|
|
101
|
+
assert_equal 2, User.where(role: %w[admin moderator]).count
|
|
102
|
+
assert_equal 2, User.where(role: %i[admin moderator]).count
|
|
103
|
+
assert_equal(
|
|
104
|
+
2,
|
|
105
|
+
User.where(role: [Role.find(:admin), Role.find(:moderator)]).count
|
|
106
|
+
)
|
|
107
|
+
assert_equal 1, User.where.not(role: %w[admin moderator]).count
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_where_with_array_of_invalid_keys_raises
|
|
111
|
+
assert_raises(RuntimeError) { User.where(role: %w[admin nope]).to_a }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Direct probe on `serializable?` — guards against re-introducing the inverted
|
|
115
|
+
# `exclude?` logic that silently dropped valid keys from `HomogeneousIn` binds.
|
|
116
|
+
def test_serializable_predicate
|
|
117
|
+
type = User.type_for_attribute(:role)
|
|
118
|
+
assert type.serializable?('admin')
|
|
119
|
+
assert type.serializable?(:admin)
|
|
120
|
+
assert type.serializable?(Role.find(:admin))
|
|
121
|
+
assert type.serializable?(nil)
|
|
122
|
+
assert type.serializable?(%w[admin guest])
|
|
123
|
+
assert type.serializable?([:admin, Role.find(:guest)])
|
|
124
|
+
refute type.serializable?(42) # rubocop:disable Rails/RefuteMethods
|
|
125
|
+
refute type.serializable?([42]) # rubocop:disable Rails/RefuteMethods
|
|
126
|
+
end
|
|
127
|
+
|
|
89
128
|
def test_model_readers_writers_with_different_class_name
|
|
90
129
|
pia = User.new(locale: :en)
|
|
91
130
|
pia.de!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anchormodel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sandro Kalbermatter
|
|
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
263
263
|
- !ruby/object:Gem::Version
|
|
264
264
|
version: '0'
|
|
265
265
|
requirements: []
|
|
266
|
-
rubygems_version: 4.0.
|
|
266
|
+
rubygems_version: 4.0.11
|
|
267
267
|
specification_version: 4
|
|
268
268
|
summary: Bringing object-oriented programming to Rails enums
|
|
269
269
|
test_files: []
|