yaaf 3.0.0 → 3.0.2

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: a08134d9d3b15971a99db839a00273b53f897bde92028f6d46bd7d0fc307f708
4
- data.tar.gz: 68dff51038255d989e78a520cc5ab4f68f7ec58bcdfbd79a33e60f8e93495f03
3
+ metadata.gz: dbd86cb443765e32aeb6af11e0808962cbc4e21686931e36430be97497a96b34
4
+ data.tar.gz: ea8597893601325795fd2f754958d716e8b9fbc387eb3022d80f1426823aa968
5
5
  SHA512:
6
- metadata.gz: '02596873efdbc3583db3db80735556beded04f474acad21c3fd11b13533ef974ffe377aac5c0471fea20b7873dfa549be4f5d760eaeaeb9d7f0b8d2185966393'
7
- data.tar.gz: 9fe3d61482b252e35c0a88c867764fc4971da5b926976762bf55c166caedec28e7b047a755767afdd58e2d7ca10bee99c955ac6394bf54f5aaabd1817c8e0c97
6
+ metadata.gz: 99e1eb0a6cf12be82c76d7f8da2c610ecbcf14b7ed2873b8eddb943f2716d4ed3d972163ff278df767588cc2f580083d331b26108474446571c5e32e82bc6301
7
+ data.tar.gz: 418b22b8ca4a4cb6d1ba96d3700f245d70941cc204a4ba4d879e6c1a6183e6ef71bea2c5fcca976d490fe7170e4dc18b8b2083e37649a32e94bc4467924491d9
data/README.md CHANGED
@@ -200,7 +200,7 @@ The `#errors` method will return an `ActiveModel::Errors` object such as any oth
200
200
 
201
201
  ### #save
202
202
 
203
- The `#save` method will run validations. If it's invalid it will return `false`, otherwise it will save all the models within a DB transaction and return `true`.
203
+ The `#save` method will run validations. If it's invalid it will return `false`, otherwise it will save all the models within a DB transaction and return `true`. Models that were `#marked_for_destruction?` will be destroyed instead of saved, this can be done by calling `#mark_for_destruction` on an `ActiveRecord` model.
204
204
 
205
205
  Defined callbacks will be called in the following order:
206
206
  - `before_validation`
data/lib/yaaf/form.rb CHANGED
@@ -53,12 +53,20 @@ module YAAF
53
53
  options.merge!(validate: false)
54
54
 
55
55
  models.map do |model|
56
- model.marked_for_destruction? ? model.destroy! : model.save!(**options)
56
+ if model.respond_to?(:marked_for_destruction?) && model.marked_for_destruction?
57
+ model.destroy!
58
+ else
59
+ model.save!(**options)
60
+ end
57
61
  end
58
62
  end
59
63
 
60
64
  def validate_models
61
- models.each { |model| promote_errors(model) if model.invalid? }
65
+ models.each do |model|
66
+ next if model.respond_to?(:marked_for_destruction?) && model.marked_for_destruction?
67
+
68
+ promote_errors(model) if model.invalid?
69
+ end
62
70
  end
63
71
 
64
72
  def promote_errors(model)
data/lib/yaaf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YAAF
4
- VERSION = '3.0.0'
4
+ VERSION = '3.0.2'
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Manuel Ramallo
8
8
  - Santiago Bartesaghi
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-07-08 00:00:00.000000000 Z
12
+ date: 2024-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -137,7 +137,7 @@ dependencies:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: 1.5.0
140
- description:
140
+ description:
141
141
  email:
142
142
  - juanmanuelramallo@hey.com
143
143
  - santib@hey.com
@@ -158,7 +158,7 @@ metadata:
158
158
  source_code_uri: https://github.com/rootstrap/yaaf
159
159
  bug_tracker_uri: https://github.com/rootstrap/yaaf/issues
160
160
  changelog_uri: https://github.com/rootstrap/yaaf/releases
161
- post_install_message:
161
+ post_install_message:
162
162
  rdoc_options: []
163
163
  require_paths:
164
164
  - lib
@@ -173,8 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  requirements: []
176
- rubygems_version: 3.0.3.1
177
- signing_key:
176
+ rubygems_version: 3.5.9
177
+ signing_key:
178
178
  specification_version: 4
179
179
  summary: Easing the form object pattern in Rails applications.
180
180
  test_files: []