anchormodel 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Module: Anchormodel::Version
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -101,62 +101,6 @@
101
101
 
102
102
  <dl class="constants">
103
103
 
104
- <dt id="MAJOR-constant" class="">MAJOR =
105
- <div class="docstring">
106
- <div class="discussion">
107
-
108
-
109
- </div>
110
- </div>
111
- <div class="tags">
112
-
113
-
114
- </div>
115
- </dt>
116
- <dd><pre class="code"><span class='int'>0</span></pre></dd>
117
-
118
- <dt id="MINOR-constant" class="">MINOR =
119
- <div class="docstring">
120
- <div class="discussion">
121
-
122
-
123
- </div>
124
- </div>
125
- <div class="tags">
126
-
127
-
128
- </div>
129
- </dt>
130
- <dd><pre class="code"><span class='int'>1</span></pre></dd>
131
-
132
- <dt id="PATCH-constant" class="">PATCH =
133
- <div class="docstring">
134
- <div class="discussion">
135
-
136
-
137
- </div>
138
- </div>
139
- <div class="tags">
140
-
141
-
142
- </div>
143
- </dt>
144
- <dd><pre class="code"><span class='int'>2</span></pre></dd>
145
-
146
- <dt id="EDGE-constant" class="">EDGE =
147
- <div class="docstring">
148
- <div class="discussion">
149
-
150
-
151
- </div>
152
- </div>
153
- <div class="tags">
154
-
155
-
156
- </div>
157
- </dt>
158
- <dd><pre class="code"><span class='kw'>false</span></pre></dd>
159
-
160
104
  <dt id="LABEL-constant" class="">LABEL =
161
105
  <div class="docstring">
162
106
  <div class="discussion">
@@ -169,7 +113,7 @@
169
113
 
170
114
  </div>
171
115
  </dt>
172
- <dd><pre class="code"><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#MAJOR-constant" title="Anchormodel::Version::MAJOR (constant)">MAJOR</a></span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#MINOR-constant" title="Anchormodel::Version::MINOR (constant)">MINOR</a></span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#PATCH-constant" title="Anchormodel::Version::PATCH (constant)">PATCH</a></span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#EDGE-constant" title="Anchormodel::Version::EDGE (constant)">EDGE</a></span></span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>edge</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='kw'>nil</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span></pre></dd>
116
+ <dd><pre class="code"><span class='lparen'>(</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span> <span class='op'>/</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>VERSION</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span></pre></dd>
173
117
 
174
118
  </dl>
175
119
 
@@ -185,9 +129,9 @@
185
129
  </div>
186
130
 
187
131
  <div id="footer">
188
- Generated on Wed Jan 25 12:36:39 2023 by
132
+ Generated on Tue Apr 23 17:20:43 2024 by
189
133
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
190
- 0.9.28 (ruby-3.1.3).
134
+ 0.9.36 (ruby-3.2.2).
191
135
  </div>
192
136
 
193
137
  </div>
data/doc/Anchormodel.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Class: Anchormodel
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -116,11 +116,11 @@
116
116
  <p class="children">
117
117
 
118
118
 
119
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span>, <span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span>
119
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span>, <span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span>, <span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span>
120
120
 
121
121
 
122
122
 
123
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html" title="Anchormodel::ActiveModelTypeValue (class)">ActiveModelTypeValue</a></span>, <span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span>
123
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span>, <span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span>
124
124
 
125
125
 
126
126
  </p>
@@ -934,9 +934,9 @@
934
934
  </div>
935
935
 
936
936
  <div id="footer">
937
- Generated on Wed Jan 25 12:36:40 2023 by
937
+ Generated on Tue Apr 23 17:20:43 2024 by
938
938
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
939
- 0.9.28 (ruby-3.1.3).
939
+ 0.9.36 (ruby-3.2.2).
940
940
  </div>
941
941
 
942
942
  </div>
data/doc/_index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>
7
- Documentation by YARD 0.9.28
7
+ Documentation by YARD 0.9.36
8
8
 
9
9
  </title>
10
10
 
@@ -52,7 +52,7 @@
52
52
  <div class="clear"></div>
53
53
  </div>
54
54
 
55
- <div id="content"><h1 class="noborder title">Documentation by YARD 0.9.28</h1>
55
+ <div id="content"><h1 class="noborder title">Documentation by YARD 0.9.36</h1>
56
56
  <div id="listing">
57
57
  <h1 class="alphaindex">Alphabetic Index</h1>
58
58
 
@@ -81,7 +81,7 @@
81
81
  <ul>
82
82
 
83
83
  <li>
84
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html" title="Anchormodel::ActiveModelTypeValue (class)">ActiveModelTypeValue</a></span>
84
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span>
85
85
 
86
86
  <small>(Anchormodel)</small>
87
87
 
@@ -92,6 +92,11 @@
92
92
 
93
93
  </li>
94
94
 
95
+ <li>
96
+ <span class='object_link'><a href="AnchormodelGenerator.html" title="AnchormodelGenerator (class)">AnchormodelGenerator</a></span>
97
+
98
+ </li>
99
+
95
100
  <li>
96
101
  <span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span>
97
102
 
@@ -118,6 +123,21 @@
118
123
  </ul>
119
124
 
120
125
 
126
+ <ul id="alpha_U" class="alpha">
127
+ <li class="letter">U</li>
128
+ <ul>
129
+
130
+ <li>
131
+ <span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span>
132
+
133
+ <small>(Anchormodel)</small>
134
+
135
+ </li>
136
+
137
+ </ul>
138
+ </ul>
139
+
140
+
121
141
  <ul id="alpha_V" class="alpha">
122
142
  <li class="letter">V</li>
123
143
  <ul>
@@ -141,9 +161,9 @@
141
161
  </div>
142
162
 
143
163
  <div id="footer">
144
- Generated on Wed Jan 25 12:36:39 2023 by
164
+ Generated on Tue Apr 23 17:20:43 2024 by
145
165
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
146
- 0.9.28 (ruby-3.1.3).
166
+ 0.9.36 (ruby-3.2.2).
147
167
  </div>
148
168
 
149
169
  </div>
data/doc/class_list.html CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_Anchormodel' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span> &lt; Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Anchormodel::ActiveModelTypeValue' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html" title="Anchormodel::ActiveModelTypeValue (class)">ActiveModelTypeValue</a></span> &lt; Value<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Attribute' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span> &lt; Object<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::ModelMixin' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span><small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Version' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span><small class='search_info'>Anchormodel</small></div></li></ul></li>
46
+ <li id='object_Anchormodel' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span> &lt; Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Anchormodel::ActiveModelTypeValueSingle' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span> &lt; Value<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Attribute' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span> &lt; Object<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::ModelMixin' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span><small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Util' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span><small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Version' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span><small class='search_info'>Anchormodel</small></div></li></ul></li><li id='object_AnchormodelGenerator' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="AnchormodelGenerator.html" title="AnchormodelGenerator (class)">AnchormodelGenerator</a></span> &lt; NamedBase<small class='search_info'>Top Level Namespace</small></div></li>
47
47
 
48
48
  </ul>
49
49
  </div>
data/doc/file.README.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -68,11 +68,11 @@
68
68
 
69
69
  <p>Typically, a Rails application consists of three kinds of state:</p>
70
70
  <ul><li>
71
- <p>The code, which we can consider static within a given version. Code can reference to other code, e.g. <code>node.parent = other_node</code>.</p>
71
+ <p>The code, which we can consider static within a given version. Code can reference to other code, e.g. <code>node.parent = other_node</code>.</p>
72
72
  </li><li>
73
- <p>The database contents, which can fluctuate within the bounds of the DB schema. Data can reference to other data, ideally via foreign keys.</p>
73
+ <p>The database contents, which can fluctuate within the bounds of the DB schema. Data can reference to other data, ideally via foreign keys.</p>
74
74
  </li><li>
75
- <p>A mix of the two, where code needs to be specifically tailored for some kind of data. A prominent example of such a mix would for instance be user roles: roles must be hardcoded in the code because security logic is tied to them. However, as users are assigned to roles in the database, roles also need to be persisted in the database. This is where Anchormodel comes into play.</p>
75
+ <p>A mix of the two, where code needs to be specifically tailored for some kind of data. A prominent example of such a mix would for instance be user roles: roles must be hardcoded in the code because security logic is tied to them. However, as users are assigned to roles in the database, roles also need to be persisted in the database. This is where Anchormodel comes into play.</p>
76
76
  </li></ul>
77
77
 
78
78
  <h2 id="label-Alternatives+coviering+the+same+use+case">Alternatives coviering the same use case</h2>
@@ -96,6 +96,14 @@
96
96
  <p>In <code>application_record.rb</code>, add in the class body: <code>include Anchormodel::ModelMixin</code></p>
97
97
  </li></ol>
98
98
 
99
+ <h1 id="label-Generator">Generator</h1>
100
+
101
+ <p>For convenience, Anchormodel provides a Rails generator:</p>
102
+
103
+ <p><code>rails generate anchormodel Role</code></p>
104
+
105
+ <p>This will create <code>app/anchormodels/role.rb</code>.</p>
106
+
99
107
  <h1 id="label-Basic+example">Basic example</h1>
100
108
 
101
109
  <p><code>app/anchormodels/role.rb</code>:</p>
@@ -228,9 +236,9 @@
228
236
  </div></div>
229
237
 
230
238
  <div id="footer">
231
- Generated on Wed Jan 25 12:36:39 2023 by
239
+ Generated on Tue Apr 23 17:20:43 2024 by
232
240
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
233
- 0.9.28 (ruby-3.1.3).
241
+ 0.9.36 (ruby-3.2.2).
234
242
  </div>
235
243
 
236
244
  </div>
data/doc/frames.html CHANGED
@@ -2,13 +2,18 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Documentation by YARD 0.9.28</title>
5
+ <title>Documentation by YARD 0.9.36</title>
6
6
  </head>
7
7
  <script type="text/javascript">
8
- var match = unescape(window.location.hash).match(/^#!(.+)/);
9
- var name = match ? match[1] : 'index.html';
10
- name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
- window.top.location = name;
8
+ var mainUrl = 'index.html';
9
+ try {
10
+ var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
11
+ var name = match ? match[1] : mainUrl;
12
+ var url = new URL(name, location.href);
13
+ window.top.location.replace(url.origin === location.origin ? name : mainUrl);
14
+ } catch (e) {
15
+ window.top.location.replace(mainUrl);
16
+ }
12
17
  </script>
13
18
  <noscript>
14
19
  <h1>Oops!</h1>
data/doc/index.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -68,11 +68,11 @@
68
68
 
69
69
  <p>Typically, a Rails application consists of three kinds of state:</p>
70
70
  <ul><li>
71
- <p>The code, which we can consider static within a given version. Code can reference to other code, e.g. <code>node.parent = other_node</code>.</p>
71
+ <p>The code, which we can consider static within a given version. Code can reference to other code, e.g. <code>node.parent = other_node</code>.</p>
72
72
  </li><li>
73
- <p>The database contents, which can fluctuate within the bounds of the DB schema. Data can reference to other data, ideally via foreign keys.</p>
73
+ <p>The database contents, which can fluctuate within the bounds of the DB schema. Data can reference to other data, ideally via foreign keys.</p>
74
74
  </li><li>
75
- <p>A mix of the two, where code needs to be specifically tailored for some kind of data. A prominent example of such a mix would for instance be user roles: roles must be hardcoded in the code because security logic is tied to them. However, as users are assigned to roles in the database, roles also need to be persisted in the database. This is where Anchormodel comes into play.</p>
75
+ <p>A mix of the two, where code needs to be specifically tailored for some kind of data. A prominent example of such a mix would for instance be user roles: roles must be hardcoded in the code because security logic is tied to them. However, as users are assigned to roles in the database, roles also need to be persisted in the database. This is where Anchormodel comes into play.</p>
76
76
  </li></ul>
77
77
 
78
78
  <h2 id="label-Alternatives+coviering+the+same+use+case">Alternatives coviering the same use case</h2>
@@ -96,6 +96,14 @@
96
96
  <p>In <code>application_record.rb</code>, add in the class body: <code>include Anchormodel::ModelMixin</code></p>
97
97
  </li></ol>
98
98
 
99
+ <h1 id="label-Generator">Generator</h1>
100
+
101
+ <p>For convenience, Anchormodel provides a Rails generator:</p>
102
+
103
+ <p><code>rails generate anchormodel Role</code></p>
104
+
105
+ <p>This will create <code>app/anchormodels/role.rb</code>.</p>
106
+
99
107
  <h1 id="label-Basic+example">Basic example</h1>
100
108
 
101
109
  <p><code>app/anchormodels/role.rb</code>:</p>
@@ -228,9 +236,9 @@
228
236
  </div></div>
229
237
 
230
238
  <div id="footer">
231
- Generated on Wed Jan 25 12:36:39 2023 by
239
+ Generated on Tue Apr 23 17:20:43 2024 by
232
240
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
233
- 0.9.28 (ruby-3.1.3).
241
+ 0.9.36 (ruby-3.2.2).
234
242
  </div>
235
243
 
236
244
  </div>
data/doc/method_list.html CHANGED
@@ -54,23 +54,23 @@
54
54
 
55
55
  <li class="even ">
56
56
  <div class="item">
57
- <span class='object_link'><a href="Anchormodel.html#all-class_method" title="Anchormodel.all (method)">all</a></span>
58
- <small>Anchormodel</small>
57
+ <span class='object_link'><a href="AnchormodelGenerator.html#add_anchormodel-instance_method" title="AnchormodelGenerator#add_anchormodel (method)">#add_anchormodel</a></span>
58
+ <small>AnchormodelGenerator</small>
59
59
  </div>
60
60
  </li>
61
61
 
62
62
 
63
63
  <li class="odd ">
64
64
  <div class="item">
65
- <span class='object_link'><a href="Anchormodel/Attribute.html#anchormodel_class-instance_method" title="Anchormodel::Attribute#anchormodel_class (method)">#anchormodel_class</a></span>
66
- <small>Anchormodel::Attribute</small>
65
+ <span class='object_link'><a href="Anchormodel.html#all-class_method" title="Anchormodel.all (method)">all</a></span>
66
+ <small>Anchormodel</small>
67
67
  </div>
68
68
  </li>
69
69
 
70
70
 
71
71
  <li class="even ">
72
72
  <div class="item">
73
- <span class='object_link'><a href="Anchormodel/Attribute.html#attribute_name-instance_method" title="Anchormodel::Attribute#attribute_name (method)">#attribute_name</a></span>
73
+ <span class='object_link'><a href="Anchormodel/Attribute.html#anchormodel_class-instance_method" title="Anchormodel::Attribute#anchormodel_class (method)">#anchormodel_class</a></span>
74
74
  <small>Anchormodel::Attribute</small>
75
75
  </div>
76
76
  </li>
@@ -78,32 +78,32 @@
78
78
 
79
79
  <li class="odd ">
80
80
  <div class="item">
81
- <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>
82
- <small>Anchormodel::ModelMixin</small>
81
+ <span class='object_link'><a href="Anchormodel/Attribute.html#attribute_name-instance_method" title="Anchormodel::Attribute#attribute_name (method)">#attribute_name</a></span>
82
+ <small>Anchormodel::Attribute</small>
83
83
  </div>
84
84
  </li>
85
85
 
86
86
 
87
87
  <li class="even ">
88
88
  <div class="item">
89
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html#cast-instance_method" title="Anchormodel::ActiveModelTypeValue#cast (method)">#cast</a></span>
90
- <small>Anchormodel::ActiveModelTypeValue</small>
89
+ <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>
90
+ <small>Anchormodel::ModelMixin</small>
91
91
  </div>
92
92
  </li>
93
93
 
94
94
 
95
95
  <li class="odd ">
96
96
  <div class="item">
97
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html#changed%3F-instance_method" title="Anchormodel::ActiveModelTypeValue#changed? (method)">#changed?</a></span>
98
- <small>Anchormodel::ActiveModelTypeValue</small>
97
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#cast-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#cast (method)">#cast</a></span>
98
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
99
99
  </div>
100
100
  </li>
101
101
 
102
102
 
103
103
  <li class="even ">
104
104
  <div class="item">
105
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html#deserialize-instance_method" title="Anchormodel::ActiveModelTypeValue#deserialize (method)">#deserialize</a></span>
106
- <small>Anchormodel::ActiveModelTypeValue</small>
105
+ <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>
106
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
107
107
  </div>
108
108
  </li>
109
109
 
@@ -142,8 +142,8 @@
142
142
 
143
143
  <li class="odd ">
144
144
  <div class="item">
145
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html#initialize-instance_method" title="Anchormodel::ActiveModelTypeValue#initialize (method)">#initialize</a></span>
146
- <small>Anchormodel::ActiveModelTypeValue</small>
145
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#initialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#initialize (method)">#initialize</a></span>
146
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
147
147
  </div>
148
148
  </li>
149
149
 
@@ -157,6 +157,14 @@
157
157
 
158
158
 
159
159
  <li class="odd ">
160
+ <div class="item">
161
+ <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>
162
+ <small>Anchormodel::Util</small>
163
+ </div>
164
+ </li>
165
+
166
+
167
+ <li class="even ">
160
168
  <div class="item">
161
169
  <span class='object_link'><a href="Anchormodel.html#key-instance_method" title="Anchormodel#key (method)">#key</a></span>
162
170
  <small>Anchormodel</small>
@@ -164,7 +172,7 @@
164
172
  </li>
165
173
 
166
174
 
167
- <li class="even ">
175
+ <li class="odd ">
168
176
  <div class="item">
169
177
  <span class='object_link'><a href="Anchormodel.html#label-instance_method" title="Anchormodel#label (method)">#label</a></span>
170
178
  <small>Anchormodel</small>
@@ -172,7 +180,7 @@
172
180
  </li>
173
181
 
174
182
 
175
- <li class="odd ">
183
+ <li class="even ">
176
184
  <div class="item">
177
185
  <span class='object_link'><a href="Anchormodel/Attribute.html#optional-instance_method" title="Anchormodel::Attribute#optional (method)">#optional</a></span>
178
186
  <small>Anchormodel::Attribute</small>
@@ -180,10 +188,18 @@
180
188
  </li>
181
189
 
182
190
 
191
+ <li class="odd ">
192
+ <div class="item">
193
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#serializable%3F-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serializable? (method)">#serializable?</a></span>
194
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
195
+ </div>
196
+ </li>
197
+
198
+
183
199
  <li class="even ">
184
200
  <div class="item">
185
- <span class='object_link'><a href="Anchormodel/ActiveModelTypeValue.html#serialize-instance_method" title="Anchormodel::ActiveModelTypeValue#serialize (method)">#serialize</a></span>
186
- <small>Anchormodel::ActiveModelTypeValue</small>
201
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serialize (method)">#serialize</a></span>
202
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
187
203
  </div>
188
204
  </li>
189
205
 
@@ -204,6 +220,14 @@
204
220
  </li>
205
221
 
206
222
 
223
+ <li class="odd ">
224
+ <div class="item">
225
+ <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html#type-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#type (method)">#type</a></span>
226
+ <small>Anchormodel::ActiveModelTypeValueSingle</small>
227
+ </div>
228
+ </li>
229
+
230
+
207
231
 
208
232
  </ul>
209
233
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -84,7 +84,7 @@
84
84
 
85
85
 
86
86
 
87
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span>
87
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span>, <span class='object_link'><a href="AnchormodelGenerator.html" title="AnchormodelGenerator (class)">AnchormodelGenerator</a></span>
88
88
 
89
89
 
90
90
  </p>
@@ -100,9 +100,9 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Wed Jan 25 12:36:39 2023 by
103
+ Generated on Tue Apr 23 17:20:43 2024 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.28 (ruby-3.1.3).
105
+ 0.9.36 (ruby-3.2.2).
106
106
  </div>
107
107
 
108
108
  </div>
@@ -1,15 +1,22 @@
1
1
  # @see https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value
2
- class Anchormodel::ActiveModelTypeValue < ActiveModel::Type::Value
2
+ class Anchormodel::ActiveModelTypeValueSingle < ActiveModel::Type::Value
3
3
  def initialize(attribute)
4
4
  super()
5
5
  @attribute = attribute
6
6
  end
7
7
 
8
+ def type
9
+ :anchormodel
10
+ end
11
+
12
+ # This converts an Anchormodel instance to string for DB
8
13
  def cast(value)
9
- serialize value
14
+ value = value.presence
15
+ return value if value.is_a?(@attribute.anchormodel_class)
16
+ return @attribute.anchormodel_class.find(value)
10
17
  end
11
18
 
12
- # Implementing this instead of cast to force key validation in any case
19
+ # This converts DB or input to an Anchormodel instance
13
20
  def serialize(value)
14
21
  value = value.presence
15
22
  return case value
@@ -27,13 +34,19 @@ class Anchormodel::ActiveModelTypeValue < ActiveModel::Type::Value
27
34
  end
28
35
  end
29
36
 
30
- def deserialize(value)
31
- value = value.presence
32
- return value if value.is_a?(@attribute.anchormodel_class)
33
- return @attribute.anchormodel_class.find(value)
37
+ def serializable?(value)
38
+ return case value
39
+ when Symbol, String
40
+ @attribute.anchormodel_class.valid_keys.exclude?(value.to_sym)
41
+ when nil, @attribute.anchormodel_class
42
+ true
43
+ else
44
+ false
45
+ end
34
46
  end
35
47
 
36
- def changed?(old_value, new_value, _new_value_before_type_cast)
37
- return deserialize(old_value) != deserialize(new_value)
48
+ def changed_in_place?(raw_old_value, value)
49
+ old_value = deserialize(raw_old_value)
50
+ old_value != value
38
51
  end
39
52
  end