reform-rails 0.2.4 → 0.2.6

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: 517a3912b77e3e81b2a86ef61dfb1e3c4d552258de8f6630fb4144551447b858
4
- data.tar.gz: e30f051b92acde0a70a27d82bffd53c166a1cb9a2253c41101c126e741d08bdc
3
+ metadata.gz: e32ac394ac02ea272b9a31655ca20b65253b8a417b0f716c7f1eda516c25981b
4
+ data.tar.gz: 7e520b5e80f4669f289bccaaa8cb5f3c549123d242e42a31e52f0be6e1f1086f
5
5
  SHA512:
6
- metadata.gz: 0e35493c33bb127e2fef2be4379fff16c45f17e25718c4d39956176f08619bf6cfc8dd2019afb9fb98ed39ba12c1f52986b447e952be46671da62bfe60ae4daa
7
- data.tar.gz: 9583ec0b967f22a1611c1d808a59d9c51234cf1717bbef1c81c140eececb59e39a880547d8f7bc20634a89d6debaa750827bc3db6645fd525db0eecfbdacce58
6
+ metadata.gz: 7b433bafad6faa28202c8a246c334fa2c7c41c735196b66f98353a9bf614990960278a2dccc87203a9985ad05e09077986795d7007e7d674e9938de3886c683d
7
+ data.tar.gz: 63f646b6f6bac1062176f84da317f05d0a44e58b0c9f3e9f5bfeb8573ceb25d2e659f84561ff831ee593f4f770494e991f49b046948036a67aa87eb2ab08b472
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.2.6
2
+
3
+ * Allow to override `#persisted?` and friends with modules.
4
+
5
+ # 0.2.5
6
+
7
+ * Fix: Delegating from form object causes ArgumentError with 0.2.4 (https://github.com/trailblazer/reform-rails/issues/99)
8
+
1
9
  # 0.2.4
2
10
 
3
11
  * Fix keyword argument warning in `method_missing` (https://github.com/trailblazer/reform-rails/pull/97)
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ end
6
6
  source "https://rubygems.org"
7
7
  gemspec
8
8
 
9
- gem 'pry-byebug'
9
+ # gem 'pry-byebug'
10
10
  gem "minitest-line"
11
11
 
12
12
  case ENV["GEMS_SOURCE"]
@@ -141,9 +141,9 @@ module Reform
141
141
  messages.to_s
142
142
  end
143
143
 
144
- def add(key, error_text)
144
+ def add(key, error_text, **error_options)
145
145
  # use rails magic to get the correct error_text and make sure we still update details and fields
146
- error = @amv_errors.add(key, error_text)
146
+ error = @amv_errors.add(key, error_text, **error_options)
147
147
  error = [error.message] unless error.is_a?(Array)
148
148
 
149
149
  # using error_text instead of text to either keep the symbol which will be
@@ -171,12 +171,12 @@ module Reform
171
171
  base_errors = @amv_errors.full_messages
172
172
  form_fields = @amv_errors.instance_variable_get(:@base).instance_variable_get(:@fields)
173
173
  nested_errors = full_messages_for_nested_fields(form_fields)
174
-
174
+
175
175
  [base_errors, nested_errors].flatten.compact
176
176
  end
177
177
 
178
178
  private
179
-
179
+
180
180
  def full_messages_for_nested_fields(form_fields)
181
181
  form_fields.map { |field| full_messages_for_twin(field[1]) }
182
182
  end
@@ -4,8 +4,11 @@ module Reform::Form::ActiveModel
4
4
  extend ClassMethods
5
5
  register_feature ActiveModel
6
6
 
7
- extend Forwardable
8
- def_delegators :model, :persisted?, :to_key, :to_param, :id
7
+ delegations = Module.new do
8
+ delegate :persisted?, :to_key, :to_param, :id, to: :model
9
+ end
10
+
11
+ include delegations # now, those methods (e.g. {#persisted?}) can be overridden by another module.
9
12
 
10
13
  def to_model # this is called somewhere in FormBuilder and ActionController.
11
14
  self
@@ -1,5 +1,5 @@
1
1
  module Reform
2
2
  module Rails
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reform-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-08 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.4.6
98
+ rubygems_version: 3.2.3
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Automatically load and include all common Rails form features.