anchormodel 0.1.4 → 0.1.5

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: 393936de0294a0c3ee8d3096a38c365bce1843b4812e670034ac9037cdd61453
4
- data.tar.gz: 130e1ae1bdf5fd50dcc1c27d9c0fd7e1b81e2923088f2bf0c81ef4d7e57ccfc6
3
+ metadata.gz: 0321a1c26ba215c332b2b496cefda3a5a1459f82599dc2655e16368e53af351e
4
+ data.tar.gz: 4361b8edc741f1509f460fc579d1f3e3ded9e59f0ae1d8ff623da6bee6502f4b
5
5
  SHA512:
6
- metadata.gz: 2a9b9e0a451d772fb0c54ae36c9f437b8aab77a74eae058f381b65ba01cc62719ec0adbd5e56b674585bc5071aa239e74e1e540591a3b70bd308c66ec8bd54da
7
- data.tar.gz: f5f5326a0a77605c3a3b5b1e7139e24f5de82b4acb91d59a0624ae3965db0c2dc5dd0b0a0458b96b727bb7560a1495928ea7664b16b432427665449998eaf910
6
+ metadata.gz: a18303288bcf7aac1a46d6de54f4adc631a8ff535c37a401a39beda41f762cf2cf94d11a266367e80026fefddb3fb0174b826be9f0f5e6fb4e036286e99d4f89
7
+ data.tar.gz: 22a389c15f1cc54f9e7fb9b20b9b54683db85cbcbbd16cfc9fb42c900221665d1969c79cbfe8a3f290efaf8a472f1e2d3fed9f050b2c27b2d818abc12c3f0a03
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .rubocop.yml
2
- .yardoc
2
+ .yardoc
3
+ /pkg/*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.5 (24.04.2024)
2
+
3
+ - Enhance documentation
4
+ - Add support for simple_form
5
+
1
6
  # 0.1.4 (23.04.2024)
2
7
 
3
8
  - Stick closer to the Rails API of Value
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anchormodel (0.1.4.edge)
4
+ anchormodel (0.1.5.edge)
5
5
  rails (~> 7.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -35,7 +35,7 @@ are regular classes and can easily be extended.
35
35
 
36
36
  ### ActiveEnum
37
37
 
38
- The gem (ActiveEnum)[https://github.com/adzap/active_enum] allows to create
38
+ The gem [ActiveEnum](https://github.com/adzap/active_enum) allows to create
39
39
  Enum-like classes that can be extended. However it only supports Integer keys. I
40
40
  find this unsatisfactory, as debugging with tools like `psql` or `mysql` is made
41
41
  unnecessarily hard when you only see numbers. Keys for enums should be
@@ -116,6 +116,41 @@ puts("User #{@user.name} has role #{@user.role.label}")
116
116
  @user.role.admin? # true if and only if the role is admin (false otherwise)
117
117
  ```
118
118
 
119
+ Your form could look something like this:
120
+
121
+ ```erb
122
+ <%= form_with(model: user) do |form| %>
123
+ <%# ... %>
124
+ <%= form.collection_select :role, Role.all, :key, :label %>
125
+ <%# ... %>
126
+ <% end %>
127
+ ```
128
+
129
+ ## Using Anchormodel with Simpleform
130
+
131
+ Anchormodel has built-in support for the [simple_form](https://github.com/heartcombo/simple_form) gem by providing an input for the type `:anchormodel` which displays anchormodel attributes as a collection select.
132
+
133
+ After SimpleForm is installed, you can write your form as:
134
+
135
+ ```erb
136
+ <%= simple_form_for user do |f| %>
137
+ <%# ... %>
138
+ <%= f.input :role %>
139
+ <%# ... %>
140
+ <% end %>
141
+ ```
142
+
143
+ Or, if you prefer radio buttons instead:
144
+
145
+
146
+ ```erb
147
+ <%= simple_form_for user do |f| %>
148
+ <%# ... %>
149
+ <%= f.input :role, as: :anchormodel_radio_buttons %>
150
+ <%# ... %>
151
+ <% end %>
152
+ ```
153
+
119
154
  # Rails Enum style model methods
120
155
 
121
156
  By default, Anchormodel adds three kinds of methods for each key to the model:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
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.1.4 ruby lib
5
+ # stub: anchormodel 0.1.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "anchormodel".freeze
9
- s.version = "0.1.4".freeze
9
+ s.version = "0.1.5".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-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]
14
+ s.date = "2024-04-24"
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/ActiveModelTypeValueSingle.html".freeze, "doc/Anchormodel/Attribute.html".freeze, "doc/Anchormodel/ModelMixin.html".freeze, "doc/Anchormodel/Util.html".freeze, "doc/Anchormodel/Version.html".freeze, "doc/AnchormodelGenerator.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/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/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.5.6".freeze
19
+ s.rubygems_version = "3.5.9".freeze
20
20
  s.summary = "Bringing object-oriented programming to Rails enums".freeze
21
21
 
22
22
  s.specification_version = 4