Skip to content

Commit

Permalink
Simplify unless to if
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonk committed Nov 15, 2024
1 parent 79996bc commit 971bbad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/sequent/core/helpers/attribute_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ def attrs(args)
Sequent::Core::Helpers::DefaultValidators.for(type).add_validations_for(self, attribute)
end

next unless type.instance_of?(Sequent::Core::Helpers::ArrayWithType) ||
(included_modules.include?(ActiveModel::Validations) &&
type.included_modules.include?(Sequent::Core::Helpers::AttributeSupport))
is_array = type.instance_of?(Sequent::Core::Helpers::ArrayWithType)
needs_validation = included_modules.include?(ActiveModel::Validations) &&
type.included_modules.include?(Sequent::Core::Helpers::AttributeSupport)

associations << attribute
associations << attribute if is_array || needs_validation
end

if included_modules.include?(ActiveModel::Validations) && associations.present?
validates_with Sequent::Core::Helpers::AssociationValidator, associations: associations
end
Expand Down

0 comments on commit 971bbad

Please sign in to comment.