anchormodel 0.2.1 → 0.2.2

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: ed4bd0c17821f7d02d71d71b648f09c271e9a7e6aa5cddaf6f0cb6ec374655d6
4
- data.tar.gz: 8d0f1e82b272fd47e18615706e6a9223d578d4f393192ef7b455f0bb1256e61f
3
+ metadata.gz: a9eebd14815541c3006409bb03f45b0155db2eb083511a09f228bf57ee68dd8a
4
+ data.tar.gz: a359a0970ec983f9f50de59edb2355fa960db401a03febed48ade509d1e977ae
5
5
  SHA512:
6
- metadata.gz: 119574b8aa308a71fb3d2b71778486701bc77455938e52f940e64ce28c12927c33a28557315737f9d2faced63535c43b990359a802ce9be0a9b48b2bb4714ccb
7
- data.tar.gz: 41fd2339af1acbaa8a59cd7ea41966c30adb22dc710e2bd7a9dec56d5c6aadfd2032837e6ad8be07d9b78db3c6c9db0c7bb80d5309df6bc563e956861ba08048
6
+ metadata.gz: 1a4df45b4cbbc8c5235ddd8b52cb1e79639f2d253ffbd627e151fdeef1102584ea9280f0b383f5ac608f395a6b26d946e299b2e810e2609509d1147e2c28f1d5
7
+ data.tar.gz: 90598b9ec18955a30519e8b0fae7e8986f16ecc9c7ee00f8c9d8025118199680e735914527bc3ea35ff3e12800e67f66feacd7695af0951adcc1350063216d72
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.3
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.2.2 (14.08.2024)
2
+
3
+ - Allow passing `anchormodel_attribute` explicitely to `anchormodel` input and enhance error message
4
+ - In `anchormodel` input, fallback to searching selected value in input html options as well
5
+ - Update ruby version to 3.2.2
6
+
1
7
  # 0.2.1 (22.05.2024)
2
8
 
3
9
  - Stop enforcing include_blank for SimpleForm, due to https://github.com/heartcombo/simple_form/issues/1427
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anchormodel (0.2.1.edge)
4
+ anchormodel (0.2.2)
5
5
  rails (~> 7.0)
6
6
 
7
7
  GEM
@@ -102,7 +102,7 @@ GEM
102
102
  builder
103
103
  minitest (>= 5.0)
104
104
  ruby-progressbar
105
- net-imap (0.4.11)
105
+ net-imap (0.4.12)
106
106
  date
107
107
  net-protocol
108
108
  net-pop (0.1.2)
@@ -187,7 +187,7 @@ GEM
187
187
  webrick (~> 1.7.0)
188
188
  yard-activesupport-concern (0.0.1)
189
189
  yard (>= 0.8)
190
- zeitwerk (2.6.14)
190
+ zeitwerk (2.6.15)
191
191
 
192
192
  PLATFORMS
193
193
  x86_64-linux
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
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.1 ruby lib
5
+ # stub: anchormodel 0.2.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.2.1".freeze
9
+ s.version = "0.2.2".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Sandro Kalbermatter".freeze]
14
- s.date = "2024-05-22"
14
+ s.date = "2024-08-14"
15
15
  s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "anchormodel.gemspec".freeze, "bin/rails".freeze, "doc/Anchormodel.html".freeze, "doc/Anchormodel/ActiveModelTypeValue.html".freeze, "doc/Anchormodel/ActiveModelTypeValueMulti.html".freeze, "doc/Anchormodel/ActiveModelTypeValueSingle.html".freeze, "doc/Anchormodel/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/SimpleFormInputs.html".freeze, "doc/Anchormodel/SimpleFormInputs/Helpers.html".freeze, "doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html".freeze, "doc/Anchormodel/Util.html".freeze, "doc/Anchormodel/Version.html".freeze, "doc/AnchormodelCheckBoxesInput.html".freeze, "doc/AnchormodelGenerator.html".freeze, "doc/AnchormodelInput.html".freeze, "doc/AnchormodelRadioButtonsInput.html".freeze, "doc/_index.html".freeze, "doc/class_list.html".freeze, "doc/css/common.css".freeze, "doc/css/full_list.css".freeze, "doc/css/style.css".freeze, "doc/file.README.html".freeze, "doc/file_list.html".freeze, "doc/frames.html".freeze, "doc/index.html".freeze, "doc/js/app.js".freeze, "doc/js/full_list.js".freeze, "doc/js/jquery.js".freeze, "doc/method_list.html".freeze, "doc/top-level-namespace.html".freeze, "lib/anchormodel.rb".freeze, "lib/anchormodel/active_model_type_value_multi.rb".freeze, "lib/anchormodel/active_model_type_value_single.rb".freeze, "lib/anchormodel/attribute.rb".freeze, "lib/anchormodel/model_mixin.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_input.rb".freeze, "lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb".freeze, "lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb".freeze, "lib/anchormodel/util.rb".freeze, "lib/anchormodel/version.rb".freeze, "lib/generators/anchormodel/USAGE".freeze, "lib/generators/anchormodel/anchormodel_generator.rb".freeze, "lib/generators/anchormodel/templates/anchormodel.rb.erb".freeze, "logo.svg".freeze, "test/active_record_model/user_test.rb".freeze, "test/dummy/.gitignore".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/anchormodels/animal.rb".freeze, "test/dummy/app/anchormodels/locale.rb".freeze, "test/dummy/app/anchormodels/role.rb".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/user.rb".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/credentials.yml.enc".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/content_security_policy.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/permissions_policy.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/db/migrate/20230107173151_create_users.rb".freeze, "test/dummy/db/migrate/20240425182000_add_animals_to_users.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/db/seeds.rb".freeze, "test/dummy/lib/tasks/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/tmp/.keep".freeze, "test/dummy/tmp/pids/.keep".freeze, "test/test_helper.rb".freeze]
16
16
  s.homepage = "https://github.com/kalsan/anchormodel".freeze
17
17
  s.licenses = ["LGPL-3.0-or-later".freeze]
18
18
  s.required_ruby_version = Gem::Requirement.new(">= 3.0.0".freeze)
19
- s.rubygems_version = "3.5.9".freeze
19
+ s.rubygems_version = "3.5.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 Wed May 22 11:24:43 2024 by
403
+ Generated on Wed May 22 11:24:47 2024 by
404
404
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
405
405
  0.9.34 (ruby-3.2.2).
406
406
  </div>
@@ -687,7 +687,7 @@
687
687
  </div>
688
688
 
689
689
  <div id="footer">
690
- Generated on Wed May 22 11:24:43 2024 by
690
+ Generated on Wed May 22 11:24:47 2024 by
691
691
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
692
692
  0.9.34 (ruby-3.2.2).
693
693
  </div>
@@ -596,7 +596,7 @@
596
596
  </div>
597
597
 
598
598
  <div id="footer">
599
- Generated on Wed May 22 11:24:43 2024 by
599
+ Generated on Wed May 22 11:24:47 2024 by
600
600
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
601
601
  0.9.34 (ruby-3.2.2).
602
602
  </div>
@@ -112,7 +112,7 @@
112
112
  </div>
113
113
 
114
114
  <div id="footer">
115
- Generated on Wed May 22 11:24:43 2024 by
115
+ Generated on Wed May 22 11:24:47 2024 by
116
116
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
117
117
  0.9.34 (ruby-3.2.2).
118
118
  </div>
@@ -257,7 +257,7 @@ Affected object: </span><span class='embexpr_beg'>#{</span><span class='id ident
257
257
  </div>
258
258
 
259
259
  <div id="footer">
260
- Generated on Wed May 22 11:24:43 2024 by
260
+ Generated on Wed May 22 11:24:47 2024 by
261
261
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
262
262
  0.9.34 (ruby-3.2.2).
263
263
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed May 22 11:24:43 2024 by
117
+ Generated on Wed May 22 11:24:47 2024 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.34 (ruby-3.2.2).
120
120
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed May 22 11:24:43 2024 by
117
+ Generated on Wed May 22 11:24:47 2024 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.34 (ruby-3.2.2).
120
120
  </div>
@@ -602,7 +602,7 @@
602
602
  </div>
603
603
 
604
604
  <div id="footer">
605
- Generated on Wed May 22 11:24:43 2024 by
605
+ Generated on Wed May 22 11:24:47 2024 by
606
606
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
607
607
  0.9.34 (ruby-3.2.2).
608
608
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Wed May 22 11:24:43 2024 by
132
+ Generated on Wed May 22 11:24:47 2024 by
133
133
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.9.34 (ruby-3.2.2).
135
135
  </div>
data/doc/Anchormodel.html CHANGED
@@ -999,7 +999,7 @@
999
999
  </div>
1000
1000
 
1001
1001
  <div id="footer">
1002
- Generated on Wed May 22 11:24:43 2024 by
1002
+ Generated on Wed May 22 11:24:47 2024 by
1003
1003
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1004
1004
  0.9.34 (ruby-3.2.2).
1005
1005
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed May 22 11:24:43 2024 by
133
+ Generated on Wed May 22 11:24:47 2024 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.34 (ruby-3.2.2).
136
136
  </div>
@@ -191,7 +191,7 @@
191
191
  </div>
192
192
 
193
193
  <div id="footer">
194
- Generated on Wed May 22 11:24:43 2024 by
194
+ Generated on Wed May 22 11:24:47 2024 by
195
195
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
196
196
  0.9.34 (ruby-3.2.2).
197
197
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed May 22 11:24:43 2024 by
133
+ Generated on Wed May 22 11:24:47 2024 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.34 (ruby-3.2.2).
136
136
  </div>
@@ -130,7 +130,7 @@
130
130
  </div>
131
131
 
132
132
  <div id="footer">
133
- Generated on Wed May 22 11:24:43 2024 by
133
+ Generated on Wed May 22 11:24:47 2024 by
134
134
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
135
  0.9.34 (ruby-3.2.2).
136
136
  </div>
data/doc/_index.html CHANGED
@@ -220,7 +220,7 @@
220
220
  </div>
221
221
 
222
222
  <div id="footer">
223
- Generated on Wed May 22 11:24:43 2024 by
223
+ Generated on Wed May 22 11:24:46 2024 by
224
224
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
225
225
  0.9.34 (ruby-3.2.2).
226
226
  </div>
data/doc/file.README.html CHANGED
@@ -339,7 +339,7 @@
339
339
  </div></div>
340
340
 
341
341
  <div id="footer">
342
- Generated on Wed May 22 11:24:43 2024 by
342
+ Generated on Wed May 22 11:24:47 2024 by
343
343
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
344
344
  0.9.34 (ruby-3.2.2).
345
345
  </div>
data/doc/index.html CHANGED
@@ -339,7 +339,7 @@
339
339
  </div></div>
340
340
 
341
341
  <div id="footer">
342
- Generated on Wed May 22 11:24:43 2024 by
342
+ Generated on Wed May 22 11:24:47 2024 by
343
343
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
344
344
  0.9.34 (ruby-3.2.2).
345
345
  </div>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Wed May 22 11:24:43 2024 by
103
+ Generated on Wed May 22 11:24:47 2024 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.34 (ruby-3.2.2).
106
106
  </div>
@@ -3,12 +3,18 @@ class Anchormodel
3
3
  module Helpers
4
4
  module AnchormodelInputsCommon
5
5
  def input(wrapper_options = nil)
6
- unless object.respond_to?(:anchormodel_attributes)
7
- fail("The form field object does not appear to respond to `anchormodel_attributes`, \
8
- did you `include Anchormodel::ModelMixin` in your `application_record.rb`? Affected object: #{object.inspect}")
6
+ if object.present?
7
+ unless object.respond_to?(:anchormodel_attributes)
8
+ fail("The form field object does not appear to respond to `anchormodel_attributes`, \
9
+ did you `include Anchormodel::ModelMixin` in your `application_record.rb`? Affected object: #{object.inspect}")
10
+ end
11
+ am_attr = object.anchormodel_attributes[@attribute_name]
12
+ elsif options.key?(:anchormodel_attribute)
13
+ am_attr = options.delete(:anchormodel_attribute)
14
+ else
15
+ fail(':anchormodel input requires either an object or the input option :anchormodel_attribute, but neither is set.')
9
16
  end
10
17
 
11
- am_attr = object.anchormodel_attributes[@attribute_name]
12
18
  unless am_attr
13
19
  fail("#{@attribute_name.inspect} does not look like an Anchormodel attribute, is `belongs_to_anchormodel` called in your model? \
14
20
  Affected object: #{object.inspect}")
@@ -17,7 +23,7 @@ Affected object: #{object.inspect}")
17
23
  options[:multiple] = true if am_attr.multiple? && options[:multiple] != false # allow overriding
18
24
 
19
25
  # Attempt to read selected key from html input options "value", as the caller might not know that this is a select.
20
- selected_key = input_options[:value]
26
+ selected_key = input_options[:value].presence || options.dig(:input_html, :value)
21
27
  if selected_key.blank? && object
22
28
  # No selected key override present and a model is present, use the model to find out what to select.
23
29
  selected_am = object.send(@attribute_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchormodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-22 00:00:00.000000000 Z
11
+ date: 2024-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  - !ruby/object:Gem::Version
268
268
  version: '0'
269
269
  requirements: []
270
- rubygems_version: 3.5.9
270
+ rubygems_version: 3.5.11
271
271
  signing_key:
272
272
  specification_version: 4
273
273
  summary: Bringing object-oriented programming to Rails enums