reform-rails 0.2.5 → 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: 9d136641745a9b830812afa8cb959e3dfd016166bd08100411481ca3215f3a87
4
- data.tar.gz: d3dcb1ddb5c7d77305bd42382068e8b9fb1f5f6556682529ad742001126394cc
3
+ metadata.gz: e32ac394ac02ea272b9a31655ca20b65253b8a417b0f716c7f1eda516c25981b
4
+ data.tar.gz: 7e520b5e80f4669f289bccaaa8cb5f3c549123d242e42a31e52f0be6e1f1086f
5
5
  SHA512:
6
- metadata.gz: 98612de254f296d0000e8e942d82c7f249d5b557c97d42fdbaebec433aee338427e00df42be8f3ab106c147465f4ee9afdeac4be593b270bdb6d86e840e04c28
7
- data.tar.gz: 53e08abfcfe1a97bc91191e05159cfcb51f0f2d0d831bf3ed7ef4b7cdee90ebcf4f36d38471bd10681441f4e4762b9454706e81cd2b87d1186ef6619b53aa095
6
+ metadata.gz: 7b433bafad6faa28202c8a246c334fa2c7c41c735196b66f98353a9bf614990960278a2dccc87203a9985ad05e09077986795d7007e7d674e9938de3886c683d
7
+ data.tar.gz: 63f646b6f6bac1062176f84da317f05d0a44e58b0c9f3e9f5bfeb8573ceb25d2e659f84561ff831ee593f4f770494e991f49b046948036a67aa87eb2ab08b472
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.6
2
+
3
+ * Allow to override `#persisted?` and friends with modules.
4
+
1
5
  # 0.2.5
2
6
 
3
7
  * Fix: Delegating from form object causes ArgumentError with 0.2.4 (https://github.com/trailblazer/reform-rails/issues/99)
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,7 +4,11 @@ module Reform::Form::ActiveModel
4
4
  extend ClassMethods
5
5
  register_feature ActiveModel
6
6
 
7
- delegate :persisted?, :to_key, :to_param, :id, to: :model
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.
8
12
 
9
13
  def to_model # this is called somewhere in FormBuilder and ActionController.
10
14
  self
@@ -1,5 +1,5 @@
1
1
  module Reform
2
2
  module Rails
3
- VERSION = "0.2.5"
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.5
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-15 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.