anchormodel 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dc8f056d1710a491d181aef71c5b576302d21baaf2f0075557f71e467e5f63a
4
- data.tar.gz: 7b9d36723f5485c18de24450021e7a0822c9a479af99a556b58643fcd4375316
3
+ metadata.gz: fdf9540f2e782e151e9b60e99561a213da014a23a257d6bd5d04e4694a540638
4
+ data.tar.gz: 7f86a064ee2d94b66c66102e81ef2a2ee3997cc46557fe806c4970a733672c7c
5
5
  SHA512:
6
- metadata.gz: 0d7f310e1e5ff0a4d310408a792c5794d8f6068a8a8b01f2a650270a3e46a1a3ff7c31a4ed403eb3588f4d378b959906a881f6c03105d5a1165059bfed3a0530
7
- data.tar.gz: 60f5405f9b8f24e3477e4a37396c45409321da47826f252185f9c255bbbaa18e462243dbfc650ac113a61994a683d701689f9fb81d2bed2912d88242ab6d3136
6
+ metadata.gz: 0b1419bbd9cce3bc457517cc4a923abad741c1dfac03bec80f739889648659acaa10116c183a656a0cb4d9214ff9fce266e62575c80e44e2a52f37d0a9fa4d6d
7
+ data.tar.gz: 305d35380def57b2a5c945bc72712f40291ea1a7b4f91eeb90204cf1be9bd2aa71b808bd2bdab32e61a2fd969ed3557ce2518f94ef4bc4b11f3585e96c2c345e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.6
2
+
3
+ - Enhance support for custom collections in inputs
4
+
1
5
  # 0.2.5
2
6
 
3
7
  - Fix an issue in combination with the active_type gem, causing virtual models to always read nil on anchormodel attributes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
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.5 ruby lib
5
+ # stub: anchormodel 0.2.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.2.5".freeze
9
+ s.version = "0.2.6".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 = "2025-02-14"
14
+ s.date = "1980-01-02"
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.6.3".freeze
19
+ s.rubygems_version = "3.6.9".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 Fri Feb 14 13:25:30 2025 by
403
+ Generated on Thu Aug 7 15:55:29 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 Fri Feb 14 13:25:30 2025 by
690
+ Generated on Thu Aug 7 15:55: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 Fri Feb 14 13:25:30 2025 by
599
+ Generated on Thu Aug 7 15:55:29 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 Fri Feb 14 13:25:30 2025 by
276
+ Generated on Thu Aug 7 15:55:29 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>
@@ -210,7 +210,18 @@
210
210
  45
211
211
  46
212
212
  47
213
- 48</pre>
213
+ 48
214
+ 49
215
+ 50
216
+ 51
217
+ 52
218
+ 53
219
+ 54
220
+ 55
221
+ 56
222
+ 57
223
+ 58
224
+ 59</pre>
214
225
  </td>
215
226
  <td>
216
227
  <pre class="code"><span class="info file"># File 'lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb', line 5</span>
@@ -253,7 +264,18 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
253
264
  <span class='id identifier rubyid_sf_selection_key'>sf_selection_key</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_selected_key'>selected_key</span>
254
265
  <span class='rparen'>)</span>
255
266
 
256
- <span class='ivar'>@collection</span> <span class='op'>=</span> <span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='id identifier rubyid_am_class'>am_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='rparen'>)</span>
267
+ <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:collection</span><span class='rbracket'>]</span>
268
+ <span class='comment'># Case where collection is given as an option consisting of an array of pairs
269
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:collection</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Enumerable</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:collection</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='op'>&amp;.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>2</span>
270
+ <span class='ivar'>@collection</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:collection</span><span class='rbracket'>]</span>
271
+ <span class='kw'>else</span>
272
+ <span class='comment'># Case where collection is given as an option consisting of an array of anchormodels
273
+ </span> <span class='ivar'>@collection</span> <span class='op'>=</span> <span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:collection</span><span class='rbracket'>]</span><span class='rparen'>)</span>
274
+ <span class='kw'>end</span>
275
+ <span class='kw'>else</span>
276
+ <span class='comment'># Case where collection is not given
277
+ </span> <span class='ivar'>@collection</span> <span class='op'>=</span> <span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='id identifier rubyid_am_class'>am_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='rparen'>)</span>
278
+ <span class='kw'>end</span>
257
279
 
258
280
  <span class='id identifier rubyid_before_render_input'>before_render_input</span>
259
281
 
@@ -269,7 +291,7 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
269
291
  </div>
270
292
 
271
293
  <div id="footer">
272
- Generated on Fri Feb 14 13:25:30 2025 by
294
+ Generated on Thu Aug 7 15:55:29 2025 by
273
295
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
274
296
  0.9.37 (ruby-3.3.5).
275
297
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Fri Feb 14 13:25:30 2025 by
117
+ Generated on Thu Aug 7 15:55:29 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 Fri Feb 14 13:25:30 2025 by
117
+ Generated on Thu Aug 7 15:55:29 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>
@@ -614,7 +614,7 @@
614
614
  </div>
615
615
 
616
616
  <div id="footer">
617
- Generated on Fri Feb 14 13:25:30 2025 by
617
+ Generated on Thu Aug 7 15:55:29 2025 by
618
618
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
619
619
  0.9.37 (ruby-3.3.5).
620
620
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Fri Feb 14 13:25:30 2025 by
132
+ Generated on Thu Aug 7 15:55:29 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
@@ -1125,7 +1125,7 @@
1125
1125
  </div>
1126
1126
 
1127
1127
  <div id="footer">
1128
- Generated on Fri Feb 14 13:25:30 2025 by
1128
+ Generated on Thu Aug 7 15:55:29 2025 by
1129
1129
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1130
1130
  0.9.37 (ruby-3.3.5).
1131
1131
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Fri Feb 14 13:25:30 2025 by
133
+ Generated on Thu Aug 7 15:55: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 Fri Feb 14 13:25:30 2025 by
194
+ Generated on Thu Aug 7 15:55: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 Fri Feb 14 13:25:30 2025 by
133
+ Generated on Thu Aug 7 15:55: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 Fri Feb 14 13:25:30 2025 by
133
+ Generated on Thu Aug 7 15:55: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 Fri Feb 14 13:25:30 2025 by
223
+ Generated on Thu Aug 7 15:55:29 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 Fri Feb 14 13:25:30 2025 by
342
+ Generated on Thu Aug 7 15:55:29 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 Fri Feb 14 13:25:30 2025 by
342
+ Generated on Thu Aug 7 15:55:29 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>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Feb 14 13:25:30 2025 by
103
+ Generated on Thu Aug 7 15:55:29 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>
@@ -40,7 +40,18 @@ Affected object: #{object.inspect}")
40
40
  sf_selection_key => selected_key
41
41
  )
42
42
 
43
- @collection = collect(am_class.all)
43
+ if options[:collection]
44
+ # Case where collection is given as an option consisting of an array of pairs
45
+ if options[:collection].first.is_a?(Enumerable) && options[:collection].first&.size == 2
46
+ @collection = options[:collection]
47
+ else
48
+ # Case where collection is given as an option consisting of an array of anchormodels
49
+ @collection = collect(options[:collection])
50
+ end
51
+ else
52
+ # Case where collection is not given
53
+ @collection = collect(am_class.all)
54
+ end
44
55
 
45
56
  before_render_input
46
57
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchormodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -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: 3.6.3
266
+ rubygems_version: 3.6.9
267
267
  specification_version: 4
268
268
  summary: Bringing object-oriented programming to Rails enums
269
269
  test_files: []