anchormodel 0.1.3 → 0.1.4

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: '01259cd9abb8c08dd46ee9ebc39697fbd8eb17128bd09d8e2ffd20aca88b3c68'
4
- data.tar.gz: 93eb6c57fae4d705cee6d92e9a5e5a3c5cfd56e3cc60306e906d5654521ae586
3
+ metadata.gz: 393936de0294a0c3ee8d3096a38c365bce1843b4812e670034ac9037cdd61453
4
+ data.tar.gz: 130e1ae1bdf5fd50dcc1c27d9c0fd7e1b81e2923088f2bf0c81ef4d7e57ccfc6
5
5
  SHA512:
6
- metadata.gz: 564faa96c2eea1cc8bcbb3c05dbe9b7c86dd0a62618cff2d3ed56611a3c4a1431e1a2e1bfdaa30e7ccbd1a2a4723648aeb269ed6ef656c44daa01d21488516a3
7
- data.tar.gz: 18d9556c138412dfa107e9958a3f4bfd8e992b9a26c85bd3516d3bc7afc3bee700c72b7d915fde69787087334be8692bf6afbb77d3dab1bc233c4be7b27ee6d2
6
+ metadata.gz: 2a9b9e0a451d772fb0c54ae36c9f437b8aab77a74eae058f381b65ba01cc62719ec0adbd5e56b674585bc5071aa239e74e1e540591a3b70bd308c66ec8bd54da
7
+ data.tar.gz: f5f5326a0a77605c3a3b5b1e7139e24f5de82b4acb91d59a0624ae3965db0c2dc5dd0b0a0458b96b727bb7560a1495928ea7664b16b432427665449998eaf910
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.4 (23.04.2024)
2
+
3
+ - Stick closer to the Rails API of Value
4
+ - Enhance testing
5
+
1
6
  # 0.1.3 (19.05.2023)
2
7
 
3
8
  - Add Rails generator
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anchormodel (0.1.2)
4
+ anchormodel (0.1.4.edge)
5
5
  rails (~> 7.0)
6
6
 
7
7
  GEM
@@ -78,41 +78,41 @@ GEM
78
78
  coderay (1.1.3)
79
79
  concurrent-ruby (1.1.10)
80
80
  crass (1.0.6)
81
- date (3.3.3)
81
+ date (3.3.4)
82
82
  erubi (1.12.0)
83
- globalid (1.0.1)
84
- activesupport (>= 5.0)
83
+ globalid (1.2.1)
84
+ activesupport (>= 6.1)
85
85
  i18n (1.12.0)
86
86
  concurrent-ruby (~> 1.0)
87
87
  json (2.6.3)
88
- loofah (2.19.1)
88
+ loofah (2.22.0)
89
89
  crass (~> 1.0.2)
90
- nokogiri (>= 1.5.9)
91
- mail (2.8.0.1)
90
+ nokogiri (>= 1.12.0)
91
+ mail (2.8.1)
92
92
  mini_mime (>= 0.1.1)
93
93
  net-imap
94
94
  net-pop
95
95
  net-smtp
96
- marcel (1.0.2)
96
+ marcel (1.0.4)
97
97
  method_source (1.0.0)
98
- mini_mime (1.1.2)
98
+ mini_mime (1.1.5)
99
99
  minitest (5.17.0)
100
100
  minitest-reporters (1.5.0)
101
101
  ansi
102
102
  builder
103
103
  minitest (>= 5.0)
104
104
  ruby-progressbar
105
- net-imap (0.3.4)
105
+ net-imap (0.4.10)
106
106
  date
107
107
  net-protocol
108
108
  net-pop (0.1.2)
109
109
  net-protocol
110
- net-protocol (0.2.1)
110
+ net-protocol (0.2.2)
111
111
  timeout
112
- net-smtp (0.3.3)
112
+ net-smtp (0.5.0)
113
113
  net-protocol
114
- nio4r (2.5.8)
115
- nokogiri (1.14.0-x86_64-linux)
114
+ nio4r (2.7.1)
115
+ nokogiri (1.16.4-x86_64-linux)
116
116
  racc (~> 1.4)
117
117
  parallel (1.22.1)
118
118
  parser (3.2.0.0)
@@ -120,9 +120,9 @@ GEM
120
120
  pry (0.14.1)
121
121
  coderay (~> 1.1)
122
122
  method_source (~> 1.0)
123
- racc (1.6.2)
123
+ racc (1.7.3)
124
124
  rack (2.2.5)
125
- rack-test (2.0.2)
125
+ rack-test (2.1.0)
126
126
  rack (>= 1.3)
127
127
  rails (7.0.4)
128
128
  actioncable (= 7.0.4)
@@ -138,11 +138,13 @@ GEM
138
138
  activesupport (= 7.0.4)
139
139
  bundler (>= 1.15.0)
140
140
  railties (= 7.0.4)
141
- rails-dom-testing (2.0.3)
142
- activesupport (>= 4.2.0)
141
+ rails-dom-testing (2.2.0)
142
+ activesupport (>= 5.0.0)
143
+ minitest
143
144
  nokogiri (>= 1.6)
144
- rails-html-sanitizer (1.5.0)
145
- loofah (~> 2.19, >= 2.19.1)
145
+ rails-html-sanitizer (1.6.0)
146
+ loofah (~> 2.21)
147
+ nokogiri (~> 1.14)
146
148
  railties (7.0.4)
147
149
  actionpack (= 7.0.4)
148
150
  activesupport (= 7.0.4)
@@ -172,20 +174,20 @@ GEM
172
174
  rubocop (>= 1.33.0, < 2.0)
173
175
  ruby-progressbar (1.11.0)
174
176
  sqlite3 (1.6.0-x86_64-linux)
175
- thor (1.2.1)
176
- timeout (0.3.1)
177
+ thor (1.3.1)
178
+ timeout (0.4.1)
177
179
  tzinfo (2.0.5)
178
180
  concurrent-ruby (~> 1.0)
179
181
  unicode-display_width (2.4.2)
180
182
  webrick (1.7.0)
181
- websocket-driver (0.7.5)
183
+ websocket-driver (0.7.6)
182
184
  websocket-extensions (>= 0.1.0)
183
185
  websocket-extensions (0.1.5)
184
186
  yard (0.9.28)
185
187
  webrick (~> 1.7.0)
186
188
  yard-activesupport-concern (0.0.1)
187
189
  yard (>= 0.8)
188
- zeitwerk (2.6.6)
190
+ zeitwerk (2.6.13)
189
191
 
190
192
  PLATFORMS
191
193
  x86_64-linux
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.4
data/anchormodel.gemspec CHANGED
@@ -2,33 +2,33 @@
2
2
  # This file is auto-generated via: 'rake gemspec'.
3
3
 
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: anchormodel 0.1.3 ruby lib
5
+ # stub: anchormodel 0.1.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.1.3"
9
+ s.version = "0.1.4".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 = "2023-05-19"
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, "anchormodel.gemspec".freeze, "bin/rails".freeze, "doc/Anchormodel.html".freeze, "doc/Anchormodel/ActiveModelTypeValue.html".freeze, "doc/Anchormodel/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/Version.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.rb".freeze, "lib/anchormodel/attribute.rb".freeze, "lib/anchormodel/model_mixin.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-23"
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/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/Version.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/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, "pkg/anchormodel-0.1.3.gem".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]
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.4.13".freeze
19
+ s.rubygems_version = "3.5.6".freeze
20
20
  s.summary = "Bringing object-oriented programming to Rails enums".freeze
21
21
 
22
22
  s.specification_version = 4
23
23
 
24
- s.add_runtime_dependency(%q<rails>.freeze, ["~> 7.0"])
25
- s.add_development_dependency(%q<rake>.freeze, ["~> 13.0.6"])
26
- s.add_development_dependency(%q<pry>.freeze, ["~> 0.14.1"])
27
- s.add_development_dependency(%q<rubocop>.freeze, ["~> 1.43.0"])
28
- s.add_development_dependency(%q<rubocop-rails>.freeze, ["~> 2.17.4"])
29
- s.add_development_dependency(%q<yard>.freeze, ["~> 0.9.28"])
30
- s.add_development_dependency(%q<yard-activesupport-concern>.freeze, ["~> 0.0.1"])
31
- s.add_development_dependency(%q<minitest>.freeze, ["~> 5.17.0"])
32
- s.add_development_dependency(%q<minitest-reporters>.freeze, ["~> 1.5.0"])
33
- s.add_development_dependency(%q<sqlite3>.freeze, ["~> 1.6.0"])
24
+ s.add_runtime_dependency(%q<rails>.freeze, ["~> 7.0".freeze])
25
+ s.add_development_dependency(%q<rake>.freeze, ["~> 13.0.6".freeze])
26
+ s.add_development_dependency(%q<pry>.freeze, ["~> 0.14.1".freeze])
27
+ s.add_development_dependency(%q<rubocop>.freeze, ["~> 1.43.0".freeze])
28
+ s.add_development_dependency(%q<rubocop-rails>.freeze, ["~> 2.17.4".freeze])
29
+ s.add_development_dependency(%q<yard>.freeze, ["~> 0.9.28".freeze])
30
+ s.add_development_dependency(%q<yard-activesupport-concern>.freeze, ["~> 0.0.1".freeze])
31
+ s.add_development_dependency(%q<minitest>.freeze, ["~> 5.17.0".freeze])
32
+ s.add_development_dependency(%q<minitest-reporters>.freeze, ["~> 1.5.0".freeze])
33
+ s.add_development_dependency(%q<sqlite3>.freeze, ["~> 1.6.0".freeze])
34
34
  end
@@ -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.36
10
10
 
11
11
  </title>
12
12
 
@@ -496,9 +496,9 @@
496
496
  </div>
497
497
 
498
498
  <div id="footer">
499
- Generated on Wed Jan 25 12:36:40 2023 by
499
+ Generated on Tue Apr 23 17:20:43 2024 by
500
500
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
501
- 0.9.28 (ruby-3.1.3).
501
+ 0.9.36 (ruby-3.2.2).
502
502
  </div>
503
503
 
504
504
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Module: Anchormodel::ModelMixin
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
 
@@ -117,7 +117,7 @@
117
117
  <li class="public ">
118
118
  <span class="summary_signature">
119
119
 
120
- <a href="#belongs_to_anchormodel-class_method" title="belongs_to_anchormodel (class method)">.<strong>belongs_to_anchormodel</strong>(attribute_name, anchormodel_class = nil, optional: false, model_readers: true, model_writers: true, model_scopes: true, model_methods: nil) &#x21d2; Object </a>
120
+ <a href="#belongs_to_anchormodel-class_method" title="belongs_to_anchormodel (class method)">.<strong>belongs_to_anchormodel</strong>(*args, **kwargs) &#x21d2; Object </a>
121
121
 
122
122
 
123
123
 
@@ -151,7 +151,7 @@
151
151
  <div class="method_details first">
152
152
  <h3 class="signature first" id="belongs_to_anchormodel-class_method">
153
153
 
154
- .<strong>belongs_to_anchormodel</strong>(attribute_name, anchormodel_class = nil, optional: false, model_readers: true, model_writers: true, model_scopes: true, model_methods: nil) &#x21d2; <tt>Object</tt>
154
+ .<strong>belongs_to_anchormodel</strong>(*args, **kwargs) &#x21d2; <tt>Object</tt>
155
155
 
156
156
 
157
157
 
@@ -160,141 +160,20 @@
160
160
  </h3><div class="docstring">
161
161
  <div class="discussion">
162
162
 
163
- <p>Creates an attribute linking to an Anchormodel. The attribute should be present in the DB and the column should be named the same as <code>attribute_name.</code></p>
163
+ <p>Creates an attribute linking to an Anchormodel. The attribute should be present in the DB and the column should be of type String and named the same as <code>attribute_name</code>.</p>
164
164
 
165
165
 
166
166
  </div>
167
167
  </div>
168
168
  <div class="tags">
169
- <p class="tag_title">Parameters:</p>
170
- <ul class="param">
171
169
 
172
- <li>
173
-
174
- <span class='name'>attribute_name</span>
175
-
176
-
177
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
178
-
179
-
180
-
181
- &mdash;
182
- <div class='inline'>
183
- <p>The name and database column of the attribute</p>
184
- </div>
185
-
186
- </li>
187
-
188
- <li>
189
-
190
- <span class='name'>anchormodel_class</span>
191
-
192
-
193
- <span class='type'>(<tt>Class</tt>)</span>
194
-
195
-
196
- <em class="default">(defaults to: <tt>nil</tt>)</em>
197
-
198
-
199
- &mdash;
200
- <div class='inline'>
201
- <p>Class of the Anchormodel (omit if attribute <code>:foo_bar</code> holds a <code>FooBar</code>)</p>
202
- </div>
203
-
204
- </li>
205
-
206
- <li>
207
-
208
- <span class='name'>optional</span>
209
-
210
-
211
- <span class='type'>(<tt>Boolean</tt>)</span>
212
-
213
-
214
- <em class="default">(defaults to: <tt>false</tt>)</em>
215
-
216
-
217
- &mdash;
218
- <div class='inline'>
219
- <p>If true, a presence validation is added to the model.</p>
220
- </div>
221
-
222
- </li>
223
-
224
- <li>
225
-
226
- <span class='name'>model_readers</span>
227
-
228
-
229
- <span class='type'>(<tt>Boolean</tt>)</span>
230
-
231
-
232
- <em class="default">(defaults to: <tt>true</tt>)</em>
233
-
234
-
235
- &mdash;
236
- <div class='inline'>
237
- <p>If true, the model is given an ActiveRecord::Enum style method <code>my_model.my_key?</code> reader for each key in the anchormodel</p>
238
- </div>
239
-
240
- </li>
241
-
242
- <li>
243
-
244
- <span class='name'>model_writers</span>
245
-
246
-
247
- <span class='type'>(<tt>Boolean</tt>)</span>
248
-
249
-
250
- <em class="default">(defaults to: <tt>true</tt>)</em>
251
-
252
-
253
- &mdash;
254
- <div class='inline'>
255
- <p>If true, the model is given an ActiveRecord::Enum style method <code>my_model.my_key!</code> writer for each key in the anchormodel</p>
256
- </div>
257
-
258
- </li>
259
-
260
- <li>
261
-
262
- <span class='name'>model_scopes</span>
263
-
264
-
265
- <span class='type'>(<tt>Boolean</tt>)</span>
266
-
267
-
268
- <em class="default">(defaults to: <tt>true</tt>)</em>
269
-
270
-
271
- &mdash;
272
- <div class='inline'>
273
- <p>If true, the model is given an ActiveRecord::Enum style scope <code>MyModel.mykey</code> for each key in the anchormodel</p>
274
- </div>
275
-
276
- </li>
277
-
278
- <li>
279
-
280
- <span class='name'>model_methods</span>
281
-
282
-
283
- <span class='type'>(<tt>Boolean</tt>, <tt>NilClass</tt>)</span>
284
-
285
-
286
- <em class="default">(defaults to: <tt>nil</tt>)</em>
287
-
288
-
289
- &mdash;
290
- <div class='inline'>
291
- <p>If non-nil, this mass-assigns and overrides <code>model_readers</code>, <code>model_writers</code> and <code>model_scopes</code></p>
292
- </div>
293
-
294
- </li>
295
-
296
- </ul>
297
170
 
171
+ <p class="tag_title">See Also:</p>
172
+ <ul class="see">
173
+
174
+ <li>Parameters</li>
175
+
176
+ </ul>
298
177
 
299
178
  </div><table class="source_code">
300
179
  <tr>
@@ -302,159 +181,15 @@
302
181
  <pre class="lines">
303
182
 
304
183
 
305
- 20
306
- 21
307
- 22
308
- 23
309
- 24
310
- 25
311
- 26
312
- 27
313
- 28
314
- 29
315
- 30
316
- 31
317
- 32
318
- 33
319
- 34
320
- 35
321
- 36
322
- 37
323
- 38
324
- 39
325
- 40
326
- 41
327
- 42
328
- 43
329
- 44
330
- 45
331
- 46
332
- 47
333
- 48
334
- 49
335
- 50
336
- 51
337
- 52
338
- 53
339
- 54
340
- 55
341
- 56
342
- 57
343
- 58
344
- 59
345
- 60
346
- 61
347
- 62
348
- 63
349
- 64
350
- 65
351
- 66
352
- 67
353
- 68
354
- 69
355
- 70
356
- 71
357
- 72
358
- 73
359
- 74
360
- 75
361
- 76
362
- 77
363
- 78
364
- 79
365
- 80
366
- 81
367
- 82
368
- 83
369
- 84
370
- 85
371
- 86
372
- 87
373
- 88
374
- 89
375
- 90
376
- 91
377
- 92
378
- 93
379
- 94</pre>
184
+ 14
185
+ 15
186
+ 16</pre>
380
187
  </td>
381
188
  <td>
382
- <pre class="code"><span class="info file"># File 'lib/anchormodel/model_mixin.rb', line 20</span>
383
-
384
- <span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_anchormodel'>belongs_to_anchormodel</span><span class='lparen'>(</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='label'>optional:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>model_readers:</span> <span class='kw'>true</span><span class='comma'>,</span>
385
- <span class='label'>model_writers:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>model_scopes:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>model_methods:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
386
- <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</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_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span>
387
- <span class='id identifier rubyid_attribute_name'>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>
388
- <span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Attribute.html#initialize-instance_method" title="Anchormodel::Attribute#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</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='comma'>,</span> <span class='id identifier rubyid_optional'>optional</span><span class='rparen'>)</span>
389
-
390
- <span class='comment'># Mass configurations if model_methods was specfied
391
- </span> <span class='kw'>unless</span> <span class='id identifier rubyid_model_methods'>model_methods</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
392
- <span class='id identifier rubyid_model_readers'>model_readers</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
393
- <span class='id identifier rubyid_model_writers'>model_writers</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
394
- <span class='id identifier rubyid_model_scopes'>model_scopes</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
395
- <span class='kw'>end</span>
396
-
397
- <span class='comment'># Register attribute
398
- </span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_attribute'>attribute</span> <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
399
-
400
- <span class='comment'># Add presence validation if required
401
- </span> <span class='kw'>unless</span> <span class='id identifier rubyid_optional'>optional</span>
402
- <span class='id identifier rubyid_validates'>validates</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='label'>presence:</span> <span class='kw'>true</span>
403
- <span class='kw'>end</span>
404
-
405
- <span class='comment'># Make casting work
406
- </span> <span class='comment'># Define serializer/deserializer
407
- </span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ActiveModelTypeValue.html" title="Anchormodel::ActiveModelTypeValue (class)">ActiveModelTypeValue</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ActiveModelTypeValue.html#initialize-instance_method" title="Anchormodel::ActiveModelTypeValue#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span>
408
-
409
- <span class='comment'># Overwrite reader to force building anchors at every retrieval
410
- </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>
411
- <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'>read_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
412
- <span class='kw'>end</span>
413
-
414
- <span class='comment'># Override writer to fail early when an invalid target value is specified
415
- </span> <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_new_value'>new_value</span><span class='op'>|</span>
416
- <span class='id identifier rubyid_write_attribute'>write_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_new_value'>new_value</span><span class='rparen'>)</span><span class='rparen'>)</span>
417
- <span class='kw'>end</span>
418
-
419
- <span class='comment'># Supply serializer and deserializer
420
- </span> <span class='id identifier rubyid_attribute'>attribute</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span>
421
-
422
- <span class='comment'># Create ActiveRecord::Enum style reader directly in the model if asked to do so
423
- </span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin? and user.guest? (returning true iff role is admin/guest)
424
- </span> <span class='kw'>if</span> <span class='id identifier rubyid_model_readers'>model_readers</span>
425
- <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
426
- <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:&quot;#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
427
- <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Anchormodel reader </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>? already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_readers: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
428
- <span class='kw'>end</span>
429
- <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:&quot;#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
430
- <span class='id identifier rubyid_public_send'>public_send</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='op'>==</span> <span class='id identifier rubyid_entry'>entry</span>
431
- <span class='kw'>end</span>
432
- <span class='kw'>end</span>
433
- <span class='kw'>end</span>
434
-
435
- <span class='comment'># Create ActiveRecord::Enum style writer directly in the model if asked to do so
436
- </span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin! and user.guest! (setting the role to admin/guest)
437
- </span> <span class='kw'>if</span> <span class='id identifier rubyid_model_writers'>model_writers</span>
438
- <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
439
- <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:&quot;#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
440
- <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Anchormodel writer </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>! already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_writers: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
441
- <span class='kw'>end</span>
442
- <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:&quot;#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
443
- <span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='symbol'>:&quot;#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span>
444
- <span class='kw'>end</span>
445
- <span class='kw'>end</span>
446
- <span class='kw'>end</span>
447
-
448
- <span class='comment'># Create ActiveRecord::Enum style scope directly in the model class if asked to do so
449
- </span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin! and user.guest! (setting the role to admin/guest)
450
- </span> <span class='kw'>if</span> <span class='id identifier rubyid_model_scopes'>model_scopes</span>
451
- <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
452
- <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
453
- <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Anchormodel scope </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_scopes: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
454
- <span class='kw'>end</span>
455
- <span class='id identifier rubyid_scope'>scope</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
456
- <span class='kw'>end</span>
457
- <span class='kw'>end</span>
189
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/model_mixin.rb', line 14</span>
190
+
191
+ <span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_anchormodel'>belongs_to_anchormodel</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
192
+ <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util.html" title="Anchormodel::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_install_methods_in_model'><span class='object_link'><a href="Util.html#install_methods_in_model-class_method" title="Anchormodel::Util.install_methods_in_model (method)">install_methods_in_model</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
458
193
  <span class='kw'>end</span></pre>
459
194
  </td>
460
195
  </tr>
@@ -466,9 +201,9 @@
466
201
  </div>
467
202
 
468
203
  <div id="footer">
469
- Generated on Wed Jan 25 12:36:40 2023 by
204
+ Generated on Tue Apr 23 17:20:43 2024 by
470
205
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
471
- 0.9.28 (ruby-3.1.3).
206
+ 0.9.36 (ruby-3.2.2).
472
207
  </div>
473
208
 
474
209
  </div>