Skip to content

Commit

Permalink
Improve model destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Oct 8, 2024
1 parent a1ac5ea commit 08c0c59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ detectors:
exclude:
- 'YAAF::Form#promote_legacy_errors'
- 'YAAF::Form#save_models'
- 'YAAF::Form#validate_models'
InstanceVariableAssumption:
enabled: false
IrresponsibleModule:
Expand All @@ -46,6 +47,7 @@ detectors:
enabled: true
exclude:
- 'YAAF::Form#save_models'
- 'YAAF::Form#validate_models'
MissingSafeMethod:
enabled: false
exclude: []
Expand Down
6 changes: 5 additions & 1 deletion lib/yaaf/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def save_models(options)
end

def validate_models
models.each { |model| promote_errors(model) if model.invalid? }
models.each do |model|
next if model.respond_to?(:marked_for_destruction?) && model.marked_for_destruction?

promote_errors(model) if model.invalid?
end
end

def promote_errors(model)
Expand Down

0 comments on commit 08c0c59

Please sign in to comment.